dforsyth Posted March 4, 2013 Posted March 4, 2013 Hey everyone. I need some help getting and using the @username with an if statement. So, the goal of my script is to run a program, find the username, then send certain keys depending on that the username is. So right now, here is my code: If @Username = testuser1 Then Send("testuser1 stuff") Elseif @username = testuser2 Send("testuser2 stuff") Else Send("testuser3 stuff") EndIf Am i doing this correctly? When the script runs it i get the "Error parsing function call" pop up box. Thanks for the help in advance.
Nessie Posted March 4, 2013 Posted March 4, 2013 (edited) Hey everyone. I need some help getting and using the @username with an if statement. So, the goal of my script is to run a program, find the username, then send certain keys depending on that the username is. So right now, here is my code: If @Username = testuser1 Then Send("testuser1 stuff") Elseif @username = testuser2 Send("testuser2 stuff") Else Send("testuser3 stuff") EndIf Am i doing this correctly? When the script runs it i get the "Error parsing function call" pop up box. Thanks for the help in advance. You haven't used the " in the If statement, you don't have used Then after the end of Elseif statement. Your Send command is totally wrong Take a look on help file for Send command, and If statement. Hi! Edited March 4, 2013 by Nessie My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s). My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all! My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file
dforsyth Posted March 4, 2013 Author Posted March 4, 2013 So, in the help file there is this. If $var > 0 Then MsgBox(4096, "", "Value is positive.") ElseIf $var < 0 Then MsgBox(4096, "", "Value is negative.") Else If StringIsXDigit($var) Then MsgBox(4096, "", "Value might be hexadecimal!") Else MsgBox(4096, "", "Value is a string.") EndIf EndIf I don't see anything on using '' in the if statement. Where would this go?
Moderators JLogan3o13 Posted March 4, 2013 Moderators Posted March 4, 2013 dforsyth, in your initial post you were missing both the quotes around testuser1 and testuser2 and the Then keyword. This fails: If @Username = testuser1 Then Send("testuser1 stuff") Elseif @username = testuser2 Send("testuser2 stuff") Else Send("testuser3 stuff") EndIf This does not: If @Username = "testuser1" Then Send("testuser1 stuff") Elseif @username = "testuser2" Then Send("testuser2 stuff") Else Send("testuser3 stuff") EndIf See why now? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
dforsyth Posted March 4, 2013 Author Posted March 4, 2013 That makes perfect sense. And it is now working. Thank you guys very much
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