JohnBailey Posted June 27, 2007 Share Posted June 27, 2007 (edited) I want to put an array in the function parameter#include<Array.au3> example([1,2,3,4]) Func example($array) _ArrayDisplay($array) EndFuncANSWER: #364268 Edited June 27, 2007 by JohnBailey A decision is a powerful thing Link to comment Share on other sites More sharing options...
MisterBates Posted June 27, 2007 Share Posted June 27, 2007 I want to put an array in the function parameter #include<Array.au3> example([1,2,3,4]) Func example($array) _ArrayDisplay($array) EndFuncWhy? What are you trying to do? [u]MisterBates[/u]_____________________________________________________Suspend/Resume Windows ScreensaverWatchWindows - Window watcher/loggerUDF: Click systray menu/submenu itemsUDF: Outlook Express Folder/Message handling (+ example code)HowTo: Multiple icons in one compiled script Link to comment Share on other sites More sharing options...
JohnBailey Posted June 27, 2007 Author Share Posted June 27, 2007 I started the following thread, then realized there is too much to communicate (it's convoluted like crazy). Thus, I wanted to break the concepts and questions into separate threads and then answer my own question in the following thread:http://www.autoitscript.com/forum/index.php?showtopic=48456In a few mins, I'll post a very inefficient and messy form of what I'm wanting to do, but it will be a functioning version at least. A decision is a powerful thing Link to comment Share on other sites More sharing options...
JohnBailey Posted June 27, 2007 Author Share Posted June 27, 2007 Goto http://www.autoitscript.com/forum/index.php?showtopic=48456See why I am asking this question? A decision is a powerful thing Link to comment Share on other sites More sharing options...
sshrum Posted June 27, 2007 Share Posted June 27, 2007 You need to pass an array...otherwise your sending a string. $aStuff = array('1','2','3','4','5') example($aStuff) You can also do ByRef type passes as well when defining your function....it's up to you how you want to pass this stuff around. Sean Shrum :: http://www.shrum.net All my published AU3-based apps and utilities 'Make it idiot-proof, and someone will make a better idiot' Â Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 27, 2007 Share Posted June 27, 2007 I want to put an array in the function parameter You can build you function to accept both single values and arrays of values: _FuncTest("2") _FuncTest(3) $x = 4 _FuncTest($x) _FuncTest("2 | 4 | 6 | 8") Dim $avTest[3] = [3,4,5] _FuncTest($avTest) Func _FuncTest($Input) Local $Msg = "Processing ", $n If IsArray($Input) Then $Msg &= "multiple columns: " For $n = 0 to UBound($Input) - 1 $Msg &= $Input[$n] & " | " Next $Msg = StringTrimRight($Msg, 3) ElseIf StringInStr($Input, "|") Then $Msg &= "multiple columns: " & $Input Else $Msg &= "a single column: " & $Input EndIf MsgBox(64, "_FuncTest()", $Msg) EndFunc 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 Link to comment Share on other sites More sharing options...
JohnBailey Posted June 27, 2007 Author Share Posted June 27, 2007 You need to pass an array...otherwise your sending a string. $aStuff = array('1','2','3','4','5') example($aStuff) array isn't a function. Did you mean I should make it a function or use _ArrayCreate() ? You can also do ByRef type passes as well when defining your function....it's up to you how you want to pass this stuff around. I'm not sure how that works out with this? I don't totally understand ByRef. I've read up on it in the manual, but I don't know why it's important. (thank you thus far!) A decision is a powerful thing Link to comment Share on other sites More sharing options...
JohnBailey Posted June 27, 2007 Author Share Posted June 27, 2007 You can build you function to accept both single values and arrays of values:VERY good point. A decision is a powerful thing Link to comment Share on other sites More sharing options...
JohnBailey Posted June 27, 2007 Author Share Posted June 27, 2007 Guys check it out http://www.autoitscript.com/forum/index.ph...t=0#entry364346 A decision is a powerful thing 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