Page 1 of 1

Lib with variable arguments of variable types?

Posted: Fri Apr 08, 2005 10:39 pm
by Justin
It's possible to do a lib with functions that accept variable args of variable type?, something like CallFunction()

in the .desc file the arguments are of fixed type so it seems not possible?

Posted: Fri Apr 08, 2005 10:53 pm
by Pupil
Try to use 'ANY' as a type in the desc file, it might work?

Re: Lib with variable arguments of variable types?

Posted: Fri Apr 08, 2005 11:10 pm
by traumatic
If you're using Long as parameter type you can also pass string from
PureBasic if this helps (don't know if this is a feature though...).

Regarding varargs:
You'll need to make a different functions, 'real' varargs are not
supported.

Code: Select all

   2. Examples of variable parameters
      - - - - - - - - - - - - - - - -

   2.1 One, two or tree parameters
  
     CustomBox, String, [Long], [Long], (Title$ [, Flags [, Hidden]]) - My Custom box
     Long

     Now, you have to create 3 PB functions, named like this:
     PB_CustomBox (char *String)
     PB_CustomBox2(char *String, Long)
     PB_CustomBox3(char *String, Long, Long)

Posted: Fri Apr 08, 2005 11:59 pm
by Fred
Using 'Any', as Pupil said, is the right way. Here is for example the definition of CallFunction in the .desc:

Code: Select all

CallFunction, Long, String, [Any], [Any], [Any], [Any], [Any], [Any], [Any], [Any], [Any], [Any], [Any], [Any], [Any], [Any], [Any], [Any], [Any], [Any], [Any], [Any], (#Library, FunctionName$, [Arg1, [Arg2, ...]]) - Call a function using its name.
Long

Posted: Sat Apr 09, 2005 12:25 pm
by El_Choni
And you can use various labels in the same function, but you'll need a way to know how many args have been pushed.

Posted: Sun Apr 10, 2005 11:39 am
by Justin
thanks, i think i'll pass arguments with its type through an array. it seems there is no way to know wich type of argument has been passed from within the lib function