varargs best practice?

Andre Garzia andre at andregarzia.com
Tue Dec 7 07:31:49 EST 2010


Mark,

I don't know if you solved this but this can be solved with a trick.

function getString pVerb
  repeat with x = 2 to the paramcount
    put quote & param(x) & quote & comma after tParams
  end repeat
  delete char -1 of tParams
  get the merge of  "[[ tCommand ]]([[tParams]])"
  get ("<? return" && it && "?>")
  return the merge of it
end getString

function doCommand pVerb, pArgs
 -- do something with parameters
 -- return something
end doCommand

this way, if you call getString like this:

put getString("doCommand", "1", "2", "3") into tShoogles

you are actually calling doCommand("1","2","3")

courtesy of double merging (not guaranteed to work on iOS)

andre "merging all the way down" garzia



More information about the Use-livecode mailing list