Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
mixed variable in function call
#1
when i call ppbang(debug,string) everything is ok,
but when i try to pass an integer tp ppbang i get an error.
because p1 is declared as string.
how can i make my variables in function calls more flexible,
so that either string or integer are valid ?

Code:
Copy      Help
function $script [$p1] [$p2]
str com

str scr = script
str arg1 = p1
out scr

if (scr = debug)    
,com.format("%s(''%s'')" debug p1)
,out com
if (scr = "Bar Keys main")    
,2
,lef    
,out com
,end
else if (!p1)
,com = script
else
,com.format("%s(''%s'',''%s'')" script p1 p2)
run "ppbang.exe" com
pi
#2
We could just declare p1 and p2 as str' (then numeric to string conversion is automatic). But numbers probably must be without ". Also, variable number of arguments.

Code:
Copy      Help
;/
function $script [VARIANT'p1] [VARIANT'p2] [VARIANT'p3] [VARIANT'p4] ;;up to p30

str s.from(script "(") ss
int i
VARIANT* a=&p1

for i 0 getopt(nargs)-1
,ss=a[i]
,sel a[i].vt
,,case [VT_BSTR,VT_DATE] s.formata("''%s''," ss)
,,case else s.formata("%s," ss)
s.rtrim(','); s+")"

;out s

run "ppbang.exe" s


Forum Jump:


Users browsing this thread: 1 Guest(s)