quickbeam Posted November 13, 2018 Posted November 13, 2018 Here's something that isn't making sense. I have a variable that is false, and it prints as false, but when I do the if-then, it acts as true. Func SetConfigGui($cfgIndex) Local $kludgeVar = $UseStampVal[$cfgIndex] ; interpreter seems to have a problem here ConsoleWrite ("=> Setting GUI settings for config " & $cfgIndex & ", use stamp: " & $kludgeVar & ", key ref: " & $UDKeyRefVal[$cfgIndex] & @CRLF) If $kludgeVar = True Then If $kludgeVar = False Then ConsoleWrite ("We got system issues" & @CRLF) EndIf ConsoleWrite ("Stamp Val:" & $StampVal[$cfgIndex] & ", kludge " & $kludgeVar & @CRLF) Else ; never reached : : : EndFunc Produces: Quote => Setting GUI settings for config 2, use stamp: False, key ref: None Stamp Val:FFFFFFFFFFFFFFFFFFFFFFFF, kludge False I added the kludge variable just to eliminate the possibility of the index doing something weird.
water Posted November 13, 2018 Posted November 13, 2018 Check the type of $kludgeVar. When it is a string then you get True. $var = "False" If $var = True Then ConsoleWrite( "**" & @CRLF) ConsoleWrite(VarGetType($var) & @CRLF) $var = False If $var = True Then ConsoleWrite( "**" & @CRLF) ConsoleWrite(VarGetType($var) & @CRLF) quickbeam 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
quickbeam Posted November 13, 2018 Author Posted November 13, 2018 Wow, how'd I get this far and not know that? I use different variables the same way, I hadn't noticed a problem, but now I'm going to have double-check everything. Thanks!
BrewManNH Posted November 13, 2018 Posted November 13, 2018 BTW, this lump of code doesn't make any sense. If $kludgeVar = True Then If $kludgeVar = False Then ConsoleWrite ("We got system issues" & @CRLF) EndIf ConsoleWrite ("Stamp Val:" & $StampVal[$cfgIndex] & ", kludge " & $kludgeVar & @CRLF) Else If $kludgevar were false, it would never get to the second test to check if it's false, and if it's true, the second test would fail. So what exactly would it accomplish with these 2 tests? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
dmob Posted November 13, 2018 Posted November 13, 2018 1 hour ago, quickbeam said: Wow, how'd I get this far and not know that? I use different variables the same way, I hadn't noticed a problem, but now I'm going to have double-check everything. Thanks! I learnt that the hard way
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now