Page 1 of 1

Iterpreting string input as multi parameters

Posted: Fri May 27, 2016 9:36 am
by MaxV
Hi,
probably the solution is easy, but I can't find it.
I have this:

Code: Select all

on myfunction  tday,tMonth,tYear
end myfunction
How can I use something similar to this?

Code: Select all

put "30,12,2015" into temp
put myFunction(temp)
Does it exist some way in livecode to iterpreting string items like function parameters?

Re: Iterpreting string input as multi parameters

Posted: Fri May 27, 2016 10:09 am
by Thierry
Hi Max,

Code: Select all

on mouseUp
   put myFunction( "30,12,2015" ) &cr& \
         myFunction( 27, 5, 2016)
end mouseUp
I am aware of none, and that's how I'm dealing with this.

Code: Select all

function myFunction  tDay,tMonth,tYear
   local saveItemDelimiter
   if paramCount() is 1 then
      put the itemdelimiter into saveItemDelimiter
      put item 2 of param(1) into tMonth
      put item 3 of param(1) into tYear
      put item 1 of param(1) into tDay
      set the itemdelimiter to saveItemDelimiter
   end if
   // whatever...
   return format("Y: %s M: %s D: %s", tYear, tMonth, tDay)
end myFunction
Of course, if you don't need both forms, then remove the if...

HTH,

Thierry