Why does is condition always true ?? Code always executes Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
WalkerOfTheDay
Posts: 710
Joined: 24 Mar 2016, 03:01

Why does is condition always true ?? Code always executes

22 Aug 2019, 02:57

Hi could someone review below code ? In snippet 2, how can ik be that whatever value is in if temp := "whatever text " is always true ?? The code under snippet 2 always executes

Snippet 1:

Code: Select all

Counter := 0
No := 30
LeftPos := 33 ;links
TopPos  := 93 ;boven
ButtonTopPos := 92
Gui, +AlwaysOnTop
Gui, Font, S10 CRed Bold, Verdana
Gui, Add, Button, x320 y22 gAfmelden, Afmelden starten
Gui, Add, Button, x320 y50 gRestart, Reload
Gui, Font, S12 CDefault Bold, Verdana
Gui, Add, Text, x12 y12 h20 , SRT automatisch afmelden
Gui, Font, S8 CDefault Bold, Verdana
Gui, Add, Text, x12 y42 w80 h20 , Inpaktafel:
Gui, Add, DDL, x93 y38 w40 vTafelnummer, 1||2|3|4|5|6|
Gui, Add, Text, x33 y72 w50 h20 , PickID
Gui, Add, Text, x93 y72 w80 h20 , Vervoerder
Gui, Add, Text, x183 y72 w50 h20 , Aantal
Gui, Add, Text, x243 y72 w52 h20 , Eenheid

Loop, %No%
{
	Gui, Add, Edit, Number x%LeftPos% y%TopPos% w60 h20 vPickID%A_Index% gMyPickID Multi -0x200000 ; Multi to allow enter key to be pressed, -0x200000 so the vertical scroll isn't shown
	TopPos := TopPos+24
	
}
TopPos := 93 ; terugzetten op beginwaarde
Loop, %No%
{
	Gui, Add, DDL, x93 y%TopPos%  w80 gTransport vTransporteur%A_Index%    , PostNL||Huisman|Brief|
	Gui, Add, DDL, x193 y%TopPos% w50 vAantal%A_Index% +Center, 0|1||2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|b|p|
	Gui, Add, Edit, x243 y%TopPos% w50 h20 vEenheid%A_Index%       , Collo
	TopPos := TopPos+24
	ButtonTopPos := ButtonTopPos+24
}
GuiControl, Focus, PickID1
	
Gui, Show, x351 y51 h900 w479, Automatisch afmelden

Progress,2: CWFF0000 CTFFFFFF W200 zh0 fs12 M x1 y400, Reload: ctrl-2 `nPause: Pause `nAfsluiten: ctrl-1,, Instructies

Return

Afmelden:
Gui, Submit 

Snippet 2:

Code: Select all

Transport:
Gui, Submit, NoHide
GuiControlGet, temp, , %A_GuiControl%, 
if temp := "Huisman"
{
	MsgBox, % temp
	Regel := SubStr(A_GuiControl, 13)
	GuiControl,, Eenheid%Regel%, Pallet
}
return
Odlanir
Posts: 659
Joined: 20 Oct 2016, 08:20

Re: Why does is condition always true ?? Code always executes  Topic is solved

22 Aug 2019, 03:07

Code: Select all

if ( temp = "Huisman")
____________________________________________________________________________
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode
User avatar
WalkerOfTheDay
Posts: 710
Joined: 24 Mar 2016, 03:01

Re: Why does is condition always true ?? Code always executes

22 Aug 2019, 03:30

nvm I misread the answer. It's working fine ! Thanks !
Last edited by WalkerOfTheDay on 22 Aug 2019, 04:00, edited 1 time in total.
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Why does is condition always true ?? Code always executes

22 Aug 2019, 03:59

then it is false always. confirm it by stepping through with a debugger
WalkerOfTheDay wrote:
22 Aug 2019, 03:30
edit
Think I found the issue :D

if(temp = "Huisman") seems to work.
that certainly wasnt the issue. whitespace matters in this case not
User avatar
WalkerOfTheDay
Posts: 710
Joined: 24 Mar 2016, 03:01

Re: Why does is condition always true ?? Code always executes

22 Aug 2019, 04:06

swagfag wrote:
22 Aug 2019, 03:59
then it is false always. confirm it by stepping through with a debugger
WalkerOfTheDay wrote:
22 Aug 2019, 03:30
edit
Think I found the issue :D

if(temp = "Huisman") seems to work.
that certainly wasnt the issue. whitespace matters in this case not
Indeed I forgot to add the ( )
User avatar
WalkerOfTheDay
Posts: 710
Joined: 24 Mar 2016, 03:01

Re: Why does is condition always true ?? Code always executes

22 Aug 2019, 04:36

Still interested to learn why in my faulty code below would always execute though.

Code: Select all

if temp := "Huisman"
{
	MsgBox, % temp
	Regel := SubStr(A_GuiControl, 13)
	GuiControl,, Eenheid%Regel%, Pallet
}
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Why does is condition always true ?? Code always executes

22 Aug 2019, 04:55

:= is the assignment operator. ure not doing an equality-comparison, ure assigning the string Huisman to temp. any string other than the empty string and the string 0 evaluate to true

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: filipemb, Google [Bot], Joey5, ShatterCoder, Xaucy and 191 guests