Jump to content
Sign in to follow this  

Sending variables to functions?

Recommended Posts

I am trying to send data to a function (something quite common in php or perl but not seeing the syntax) and worse from churning through the help files i am starting to question is it not possible to send data to a function?

From the autoit help file function call reference:


The function cannot take any parameters and cannot be a built-in AutoIt function.

sooo... my workaround hacked about was to do something like.....

For $i = 1 to 2
    $ret = Call("test")
    MsgBox(4096,"", $ret)

Func test()
    If $i == 1 Then
       Return "Hello $i"

    If $i == 2 Then
       Return "Goodbye $i"

but is it not simply possible to send a variable to a function directly? (instead of having to write a handful of If statements inside of a function)

If thats not detailed enough - i am trying to make a script that has a email sending function built in - however i don't want to have to write a ton of If statments for all the different types of subject matter for the subj/body of the email... i would prefer just being able to send a variable to the function directly that can be used to populate the data.. is that possible?

Don't let that status fool you, I am no advanced memeber!

Share this post

Link to post
Share on other sites

Call is not necessary most of the time unless you need to do a dynamic call. If you call the function directly then you can pass it parameters like a normal function.


Func TestFunc($Var)
    MsgBox(0, "", $Var)
EndFunc   ;==>TestFunc
Edited by SolidSnake

HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...