Jump to content

If or then else problem [SOLVED]


Recommended Posts

i have run into a problem in my script were it does not run the else block.

i have placed msgboxes to make sure the variable in the expression id different to the values in the statement but still it fails to run the else block.

it probially is a error in how i have written it but my eyes are not seeing it, could anyone see were i have gone wrong.

case $NewuserContinueBtn
     MsgBox(1,"",$NewuserNameVar)
     if $NewuserNameVar = 0 or $NewuserNameVar = "" Then
      MsgBox(1,"",$NewuserNameVar)
      MsgBox(48,"Oops","Please Give your character a name")
     Else
      $NewuserEmailVar = GUICtrlRead($NewuserEmailIpt)

the message box is checking what the variable is, and everytime (even after the 'then' its stiff different.) yet it still fails to run the else block instead it runs the "MsgBox(48,"Oops","Please Give your character a name")"

thanks in advance for anyhelp

Edited by Thornhunt

Budweiser + room = warm beerwarm beer + fridge = too long!warm beer + CO2 fire extinguisher = Perfect![quote]Protect the easly offended ... BAN EVERYTHING[/quote]^^ hmm works for me :D

Link to comment
Share on other sites

If the variable $NewuserNameVar contains a string the comparison

$NewuserNameVar = 0
always is true because AutoIt has to convert the string to a numeric value. So before you compare check the datatype using IsInt or something similar.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

 

Link to comment
Share on other sites

ahhh thakyou verymuch, at the start of my script the variable was declared as a integer however it is then changed to a string later in the script .. ahhh typical schoolboy error.. once again thankyou

/edit

wow i still cant belive how i clear it was.

Edited by Thornhunt

Budweiser + room = warm beerwarm beer + fridge = too long!warm beer + CO2 fire extinguisher = Perfect![quote]Protect the easly offended ... BAN EVERYTHING[/quote]^^ hmm works for me :D

Link to comment
Share on other sites

Glad to be of service :D

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...