MuffettsMan Posted September 29, 2006 Share Posted September 29, 2006 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! Link to comment Share on other sites More sharing options...
FuryCell Posted September 29, 2006 Share Posted September 29, 2006 (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 September 29, 2006 by SolidSnake HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code. Link to comment Share on other sites More sharing options...
MHz Posted September 29, 2006 Share Posted September 29, 2006 For $i = 1 to 2 $ret = test("some test") MsgBox(4096,"", $ret) Next Func test($parameter) If $i = 1 Then Return "Hello " & $i & " " & $parameter EndIf If $i = 2 Then Return "Goodbye " & $i & " " & $parameter EndIf EndFunc Link to comment Share on other sites More sharing options...
MuffettsMan Posted September 29, 2006 Author Share Posted September 29, 2006 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! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now