Jump to content
Sign in to follow this  
Distrophy

send() a changing variable

Recommended Posts

Distrophy

I need help on how to go about coding this.

I have a list of about 25 variables that will be set, but I want to have them print out when I call a function.

$var1 = example
$var2 = example
$var3 = example
etc....
$var 25= example

Func Print()

$int = 1

While $int<26
    BeforeFunc()

    Send($var & $int)   

    AfterFunc()
    $int = $int+1
Wend
EndFunc

What my code does now is print out "example1" "example2" "example3" instead of what is actually contained within the variables.

I know there's probably an easy way to do this. Thanks for the help.

EDIT: I figured it out using an array to store the variables and then using the while to increase the value.

Edited by Distrophy

Share this post


Link to post
Share on other sites
PsaltyDS

I need help on how to go about coding this.

I have a list of about 25 variables that will be set, but I want to have them print out when I call a function.

What my code does now is print out "example1" "example2" "example3" instead of what is actually contained within the variables.

I know there's probably an easy way to do this. Thanks for the help.

EDIT: I figured it out using an array to store the variables and then using the while to increase the value.

Arrays are the way to go, but your loop is still more complicated than you need. Use For/Next and let that increment the index for you:

Global $avVar[25] = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", _
    "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y"]

Func Print()

For $i = 0 To UBound($avVar) - 1
    BeforeFunc()
    Send($avVar[$i])
    AfterFunc()
Next

:)

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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.