Sign in to follow this  
Followers 0
MuffettsMan

Sending variables to functions?

4 posts in this topic

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:

Remarks

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)
Next

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

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

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



#2 ·  Posted (edited)

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.

TestFunc("Hello")

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

WHoooOOoOOOT happy days are here again thx guys :)

luv autoit... it makes my life sooo lazy


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

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