Jump to content

function args, is there a way


Recommended Posts

Well that's hard to give an example here but I'll try...

Foo('d','da','dad') // call the function with three arguments

Func Foo(@args) // the variables get auto initiated as locals as one array with something like @args as a counter...

FOR $a = 1 TO @args

ConsoleWrite($arg[$a] & @CR)

Next

EndFunc

Something like this, it would be nice not to make an array before but just cast it on to the function and this take care of making these arguments into an array local...

I know this is more to expect but...

kjactive :(

Edited by kjactive
Link to comment
Share on other sites

Have you looked at the macro:

@NumParams

Number of parameters used in calling the user function.

But the macro does not do the array concept.

Func Foo($one, $two, $three)
   FOR $a = 1 TO @NumParams
      ConsoleWrite($arg[$a] & @CR)
   Next
EndFunc
Link to comment
Share on other sites

One approach is to pass an array to a function which can have different sizes.

Func Max(ByRef $array)
    Dim $i, $retval

    If Not IsArray($array) Then
        return $array ; The only thing, so it must be the largest
    Endif
    $retval = $array[0]
    For $i = 1 to UBound($array)-1
         If $retval < $array[$i] Then
              $retval = $array[$i] 
         Endif
    Next
    return $retval
EndFunc
Edited by Nutster

David Nuttall
Nuttall Computer Consulting

An Aquarius born during the Age of Aquarius

AutoIt allows me to re-invent the wheel so much faster.

I'm off to write a wizard, a wonderful wizard of odd...

Link to comment
Share on other sites

Well if there is a parameter to scope 'how many arguments send to a function' then it would be easy ( I think ) to do the array concept - wouldn't that be nice and come in handy?

kjactive :(

Edited by kjactive
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...