Why are my variables getting deleted?? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
skyth540
Posts: 72
Joined: 24 Aug 2022, 10:07

Why are my variables getting deleted??

Post by skyth540 » 08 Dec 2022, 12:30

This isn't working anymore, I have no idea what's wrong with it. It checks to see what the text in a fragile text box is, and saves it if it is open and something is in it.


Code: Select all

#Persistent


SetTimer, hpiback, 10000
hpiback:
ControlGetText, buhpi, Edit1, Progress Note
;msgbox here tested to have the correct %buhpi%
If (buhpi !:= "")
{
FileDelete, C:\Users\USER\Desktop\HPI Backup.txt
sleep, 10
;msgbox here tested to have the incorrect %buhpi%
FileAppend, %buhpi%, C:\Users\USER\Desktop\HPI Backup.txt
}
Sleep, 10000
Last edited by gregster on 08 Dec 2022, 12:41, edited 1 time in total.
Reason: Code tags added. Please use them yourself, next time! Thank you.

User avatar
flyingDman
Posts: 2817
Joined: 29 Sep 2013, 19:01

Re: Why are my variables getting deleted??

Post by flyingDman » 08 Dec 2022, 12:37

try:

Code: Select all

buhpi := 123
if (buhpi !:= "")
	msgbox % buhpi
then try:

Code: Select all

buhpi := 123
if (buhpi != "")
	msgbox % buhpi
14.3 & 1.3.7

skyth540
Posts: 72
Joined: 24 Aug 2022, 10:07

Re: Why are my variables getting deleted??

Post by skyth540 » 08 Dec 2022, 17:45

flyingDman wrote:
08 Dec 2022, 12:37
try:

Code: Select all

buhpi := 123
if (buhpi !:= "")
	msgbox % buhpi
then try:

Code: Select all

buhpi := 123
if (buhpi != "")
	msgbox % buhpi


weird. The one without the : makes it work. Why is that?

User avatar
flyingDman
Posts: 2817
Joined: 29 Sep 2013, 19:01

Re: Why are my variables getting deleted??  Topic is solved

Post by flyingDman » 08 Dec 2022, 17:49

:= assigns a value = used in an if statement compares 2 variables. !:= is an "anomaly" and when you use var !:= 123 on a separate line, it will give an error (this line does not contain a recognized action).
14.3 & 1.3.7

Post Reply

Return to “Ask for Help (v1)”