Sign in to follow this  
Followers 0
fireking300

Need help with IF THEN

10 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Ty alot for your help JFee

Share this post


Link to post
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!"

Share this post


Link to post
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" )

Share this post


Link to post
Share on other sites

Yeah I named my Username Merritt-pc JFee helped me get it work

Share this post


Link to post
Share on other sites

I'll Use yours since its correct grammer Daram

Share this post


Link to post
Share on other sites

Im fixing to test if you can store more than one $Username

Share this post


Link to post
Share on other sites

I take it you're exclusively a GRAMMAR freak, not a spelling freak muttley


Regards,Josh

Share this post


Link to post
Share on other sites

Well I created 2 users and two different messages in the program and it worked.

Share this post


Link to post
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
Sign in to follow this  
Followers 0