Variable Number of Parameters << Back



Most of you know of using "Num_Arguments" to determine how many parameters are being passed to a function/procedure. However there is this little trick (not documented) that most of the DF old timers know. The trick to retrieve all the parameters within a function/procedure without addressing the parameters by name / defining the parameters.

Use UI

Procedure ShowParameters
	String sParam
	Integer iIndex
	For iIndex From 1 to Num_Arguments
		Move iIndex& to sParam
		Showln sParam
	Loop
End_Procedure

Send ShowParameters "Hello" "World" "Variable" 123 True "Yay"
InKey FieldIndex
Here is a neat function for comparing values. FYI, you can't pass more parameters to a global function that has fewer parameters defined. Thus, the long parameter list below.
Use UI

// You can have up to 30+ parameters as I recall
Function InSet Global String sValue String s1 String s2 String s3 String s4 String s5 String s6 String s7 String s8 String s9 Returns Boolean
	String sParam
	Integer iIndex
	For iIndex From 2 to Num_Arguments // Starts from 2 instead of 1
		Move iIndex& to sParam
		If (sValue=sParam) Function_Return True
	Loop
	Function_Return False
End_Function

If (InSet(sState,"TX","OK","KS","NE","SD","ND")) Showln "Central Time Zone"
InKey FieldIndex
Free Web Hosting