ChiGGz Posted January 21, 2008 Share Posted January 21, 2008 (edited) Lets say I have this ;how would i accomplish something like this without assigning the three numbers a variable. add3Num([1,2,10]) Func add3Num(3nums) 3num[0] + 3num[1]+3num[2] EndFunc Also, how do I get the size of an array? TIA! This is just a sample so you get an idea, i know theres other ways of accomplishing this without arrays.... Edited January 21, 2008 by ChiGGz Link to comment Share on other sites More sharing options...
stampy Posted January 21, 2008 Share Posted January 21, 2008 Not sure I understand your first question. To pass the data into a function you would need to use some sort of variable. What are you trying to get out of it? For the size of the array you can use ubound. Link to comment Share on other sites More sharing options...
ChiGGz Posted January 21, 2008 Author Share Posted January 21, 2008 Not sure I understand your first question. To pass the data into a function you would need to use some sort of variable. What are you trying to get out of it? That's just it, I want to pass it with no variable. I've come up with this method right now. add3Num(StringSplit("2,5,29", ",")) Stringsplit is ugly though Link to comment Share on other sites More sharing options...
stampy Posted January 21, 2008 Share Posted January 21, 2008 why are you trying to avoid a variable? The variable in the function will still be needed. Link to comment Share on other sites More sharing options...
ChiGGz Posted January 21, 2008 Author Share Posted January 21, 2008 why are you trying to avoid a variable? The variable in the function will still be needed.It's for regression testing. Each function will be reused many times for different cases. I'm trying to have some sort of standard where a tester would only be required to input values straight into the function call. Link to comment Share on other sites More sharing options...
randallc Posted January 21, 2008 Share Posted January 21, 2008 That's just it, I want to pass it with no variable. I've come up with this method right now. add3Num(StringSplit("2,5,29", ",")) Stringsplit is ugly though Hi, Hard to know what you mean.. MsgBox(0,"","add3Num(1,2,10)="&add3Num(1,2,10) ) Func add3Num($n1nums,$n2nums,$n3nums) return $n1nums+$n2nums+$n3nums EndFunc Best, Randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 21, 2008 Share Posted January 21, 2008 It's for regression testing. Each function will be reused many times for different cases. I'm trying to have some sort of standard where a tester would only be required to input values straight into the function call. You're not making any sense at all. Please post an example of one of these functions. The code you have posted so far is invalid and does nothing. That makes it hard to use as an example for understanding what you are saying. For example: "add3Num([1,2,10])" will only cause the script to crash because of egregious syntax errors. Then this: "Func add3Num(3nums) 3num[0] + 3num[1]+3num[2] EndFunc" Attempts to make array references where no array is declared. AutoIt variables start with a dollar sign (i.e. $3nums), so that's wrong. You add three numbers together but don't save the sum anywhere or return it from the function. How are you going to do "regression testing" with AutoIt if you can't code a valid one-line function in AutoIt...??? 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...
ChiGGz Posted January 21, 2008 Author Share Posted January 21, 2008 You're not making any sense at all. Please post an example of one of these functions. The code you have posted so far is invalid and does nothing. That makes it hard to use as an example for understanding what you are saying. For example: "add3Num([1,2,10])" will only cause the script to crash because of egregious syntax errors. Then this: "Func add3Num(3nums) 3num[0] + 3num[1]+3num[2] EndFunc" Attempts to make array references where no array is declared. AutoIt variables start with a dollar sign (i.e. $3nums), so that's wrong. You add three numbers together but don't save the sum anywhere or return it from the function. How are you going to do "regression testing" with AutoIt if you can't code a valid one-line function in AutoIt...??? "add3Num([1,2,10])" was only an example of what I was trying to illustrate as per the comment";how would i accomplish something like this without assigning the three numbers a variable. ". It was not meant to have proper syntax, as well as the exclusion of $ for array 3num. I just wanted to know if there is a way to pass an array of numbers without storing it into a variable first. I've accomplished this via " add3Num( StringSplit ("1,9,44", ",") ) " Thanks Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 21, 2008 Share Posted January 21, 2008 "add3Num([1,2,10])" was only an example of what I was trying to illustrate as per the comment";how would i accomplish something like this without assigning the three numbers a variable. ". It was not meant to have proper syntax, as well as the exclusion of $ for array 3num. I just wanted to know if there is a way to pass an array of numbers without storing it into a variable first. I've accomplished this via " add3Num( StringSplit ("1,9,44", ",") ) " Thanks Hmm... that's still an array input to the function. So the function usage would be like this: add3Num(StringSplit ("1,9,44", ",")) Func add3Num($avInput) Local $RET = 0 For $n = 0 to UBound($avInput) - 1 $RET += $avInput[$n] Next MsgBox(64, "Result", "$RET = " & $RET) EndFunc Anyway, glad you figured it out. 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...
stampy Posted January 21, 2008 Share Posted January 21, 2008 Are you saying you don't want a variable outside of the function? If that is so then using an array or other variable inside the function would still work. As in the array that PsaltyDS shows or just variables. add3Num(1,9,44) Func add3Num($x,$y,$z) return $x+$y+$z EndFunc Link to comment Share on other sites More sharing options...
ChiGGz Posted January 22, 2008 Author Share Posted January 22, 2008 Hmm... that's still an array input to the function. So the function usage would be like this: add3Num(StringSplit ("1,9,44", ",")) Func add3Num($avInput) Local $RET = 0 For $n = 0 to UBound($avInput) - 1 $RET += $avInput[$n] Next MsgBox(64, "Result", "$RET = " & $RET) EndFunc Anyway, glad you figured it out. Oh, forgot about moving stringsplit into the func. I'm glad you mentioned it Yes that will be much easier on the eyes. 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