Jump to content
Sign in to follow this  
ericnail

How to change global Variables

Recommended Posts

ericnail

Okay, first off, I'm new here, and I appreciate you guys setting up a forum for users like me :P

Anyway,

Here is my issue:

I am new and trying to make a script, however, I am having an issue I need help with. I want to have a full script, however based on the situation, you would need to run a different script for each, when I think that I could have the script auto-detect the situation and change itself accordingly.

For Instance

could I, say, do this?:

(Say I have 3 situations each needing their own script; "Script One", "Script Two", and "Script Three" -- "$Var" would be the situation parameter/id and would be numbered numerically. (Sorry for the OxyMoron :())

If $Var = 1 Then

<Copy&Paste of "Script One">

EndIf

If $Var = 2 Then

<Copy&Paste of "Script Two">

EndIf

If $Var = 3 Then

<Copy&Paste of "Script Three">

EndIf

Basically I would just be pasting my full 3 working scripts into a new script containing these three IF..Then statements in order to have the script recognize which (Sub)script to run??

Sorry if this is a stupid/unworthy question, but I've done my best to look all over and I've done trial and error, yet still no luck. :mellow:

I'm very new, as in I just downloaded AutoIT less than 2 days ago :lol:

As for what this is for (I read the rules): I don't want you to think I'm using this script for a malicious purpose, so I'll explain as best I can what it is. I would post it here, but my personal log in info is weaved inside in many many forms. Basically, it's a script to recognize which folder (on my Web-server) I am in (via File Manager) and retrieve my local changes to text and update the server-side version with my local text.. if that makes sense?? Anyhow, I am currently stuck using different working scripts for each folder/page which is 30+ scripts. So one self-servicing script would be a Godsend!

Any help will be GREATLY appreciated!!

Thanks Again,

Eric

Edited by ericnail

Share this post


Link to post
Share on other sites
gcue

folks might help if your script was further developed...

but from what you have i think this is what you want:

if $var = 1 then
function1()
endif

if $var = 2 then
function2()
endif

if $var = 3 then
function3()
endif

func function1()
[do stuff]
endfunc

func function2()
[do stuff]
endfunc

func function3()
[do stuff]
endfunc

good luck and welcome to autoit =)

Share this post


Link to post
Share on other sites
ericnail

Thanks for the Super-Fast Reply :mellow:

Well, basically what I am trying to do is take 3 working, full, scripts (which include IF,While, etc. statements) and place them all into the same script and have the script figure out which script to run?

Or even just have a loader that would recognize, then run the appropriate script.

-- I am using 3 as an example, i actually have roughly 34 scripts which will likely grow to an even larger number in time.

Thanks,

~Eric

Edited by ericnail

Share this post


Link to post
Share on other sites
gcue

lookup "case" help file index

Edited by gcue

Share this post


Link to post
Share on other sites
ericnail

lookup "case" help file index

Wow! Thanks man, I looked at the select earlier and never thought of it again, but I believe this "Case" is exactly what I need :mellow:

You Rock,

Eric

Also, Is there a way to say for instance:

If $Variable1 <> X Then

Ignore $Variable1 for the remainder of script or until restarted

EndIf

Share this post


Link to post
Share on other sites
gcue

if you're within a while loop you can exitloop

while 1

if $x = "bleh" then exitloop

wend

Share this post


Link to post
Share on other sites
ericnail

if you're within a while loop you can exitloop

while 1

if $x = "bleh" then exitloop

wend

What does the "1" stand for?

Also, I have it check lines of text, like:

If <line1text> = <localtext> Then

exitloop

ElseIf cmd($replace text)

EndIf

If <line2text> = <localtext> Then

exitloop

ElseIf cmd($replace text)

EndIf

^^ do that for each line, obviously "ReplaceText" is not the right command, but you get the idea.

Would that work?

Edited by ericnail

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.