Something that could allow the implementation of the MIN() VFP function as close as possible to:
Code: Select all
MIN(eExpression1, eExpression2 [, eExpression3 ...])
Code: Select all
MIN(eExpression1, eExpression2 [, eExpression3 ...])
Code: Select all
FUNCTION UntypedFunc() CLIPPER
FOR LOCAL n := 1 AS INT UPTO pcount()
? "Parameter" , n , "=" , _GetFParam(n)
NEXT
RETURN NIL
Code: Select all
FUNCTION TypedFunc([ParamArray] aParams AS OBJECT[]) AS VOID STRICT
FOR LOCAL n := 1 AS INT UPTO aParams:Length
? "Parameter" , n , "=" , aParams[n]
NEXT
Post by Karl-Heinz »
Code: Select all
LOCAL c := "Wall" AS STRING
?
TypedFunc ( 1 , TRUE , , c )
?
TypedFunc ()
// FUNCTION TypedFunc([ParamArray] aParams AS OBJECT[]) AS VOID STRICT
FUNCTION TypedFunc( aParams PARAMS OBJECT[] ) AS VOID STRICT
? "Param count:" , aParams:Length
FOREACH VAR a IN aParams
? ValType ( a ) , a , IsNil ( a ) // ok
NEXT
RETURN
Post by Karl-Heinz »
thanks, already thought that this would not work.Chris wrote:Hi Karl-Heinz,
No, you can't pass params by reference like that...
Code: Select all
FUNCTION MyTestFunc(a PARAMS OBJECT[]) AS VOID
? a[1]:GetType():FullName
? a[2]:GetType():FullName
? a[3]:GetType():FullName
? a[4]:GetType():FullName
RETURN
Code: Select all
MyTestFunc( NULL_PTR, "abc", (DWORD)1, NULL_STRING )
Type information lost for a[4]a[1]: System.IntPtr, OBJECT {PTR}
a[2]: System.String, OBJECT {STRING}
a[3]: System.UInt32, OBJECT {DWORD}
a[4]: null, OBJECT // exception
Type information lost for a[1] and a[4]a[1]: null, OBJECT // exception
a[2]: System.String, OBJECT {STRING}
a[3]: System.UInt32, OBJECT {DWORD}
a[4]: null, OBJECT // exception
Code: Select all
System.IntPtr
System.String
System.UInt32
System.String
Code: Select all
IntPtr.Zero
Code: Select all
(long)IntPtr.Zero
Code: Select all
FUNCTION MyTestFunc(p AS PTR, a PARAMS OBJECT[]) AS VOID
RETURN
Code: Select all
MyTestFunc( NULL_PTR, NULL_PTR, "abc", (DWORD)1, NULL_STRING )