Iterpreting string input as multi parameters

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Iterpreting string input as multi parameters

Post by MaxV » Fri May 27, 2016 9:36 am

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?
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Thierry
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 875
Joined: Wed Nov 22, 2006 3:42 pm

Re: Iterpreting string input as multi parameters

Post by Thierry » Fri May 27, 2016 10:09 am

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
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!

Post Reply