Jump to content

Help With Username and If statement


Recommended Posts

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.

Link to comment
Share on other sites

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 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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

  • Moderators

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!

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...