Jump to content

Need help with IF THEN


Recommended Posts

I need help with command If and Then

I want it to be something like this

If @username = Merritt-PC

Then Merritt-PC = Daniel

Its Something like that but I have no Idea what to do to make it work.

So when

MsgBox(4096,"Welcome","The time is " & @hour & ":" & @min & ". " & @username & " Your Welcome" )

@username shows up Daniel instead of Merritt-pc

I know I can just replace @username with Daniel But I want to do it this way.

Edited by fireking300
Link to comment
Share on other sites

You can't change @username... it is a macro, not a variable.

What you can do is create a variable and use it in the msgbox instead of @username

Global $username

If @UserName = "Merritt-PC" Then $username = "Daniel"

MsgBox(4096,"Welcome","The time is " & @hour & ":" & @min & ". " & $username & " Your Welcome" )

Regards,Josh

Link to comment
Share on other sites

Are you sure it's @UserName that contains Merritt-PC? That looks more like it would be the result of @ComputerName. @UserName is the currently logged on user.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Probably want to set the default also (and me being a Grammer Freak, the message text) muttley

Global $username = @UserName

If @UserName = "Merritt-PC" Then $username = "Daniel"

MsgBox(4096,"Welcome","The time is " & @hour & ":" & @min & ". " & $username & " You are Welcome" )

You can't change @username... it is a macro, not a variable.

What you can do is create a variable and use it in the msgbox instead of @username

Global $username

If @UserName = "Merritt-PC" Then $username = "Daniel"

MsgBox(4096,"Welcome","The time is " & @hour & ":" & @min & ". " & $username & " Your Welcome" )
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...