Page 1 of 1

Parsing string in an array

Posted: Wed Feb 26, 2014 9:36 pm
by tasdvl9
Hi All,

Trying to figure out the best way to parse the date/time from my array.

Presently I am storing this value in my array "12/09/14 @ 06:58:05PM"

In Livecode what is the preferred method of parsing that string out to only give me this: "12/09/14"

Thanks!

Re: Parsing string in an array

Posted: Wed Feb 26, 2014 9:45 pm
by dunbarx
Hi.

Is that string a single element in the array? Or are they separate elements in a multi-dimensional array. I suspect the former.

In that case you will want to separate the two part of that string. Perhaps you can set the itemdelimiter to "@" and extract the first item. You may want to delete trailing spaces, if there are any.

Craig Newman

Re: Parsing string in an array

Posted: Wed Feb 26, 2014 9:46 pm
by FourthWorld
The space character is used natively as a delimiter for words, so you could write:

Code: Select all

put word 1 of tTimeStamp into tDateOnlyVar
We might need to modify that depending on how these are used in your array. Is the time stamp the key or the value?

Re: Parsing string in an array

Posted: Wed Feb 26, 2014 9:49 pm
by tasdvl9
Thanks, Craig!

Much appreciated.

Re: Parsing string in an array

Posted: Wed Feb 26, 2014 9:59 pm
by dunbarx
Hi.

Richard's suggestion is simpler.

More importantly, you need to become familiar with these sorts of tools. It requires a certain amount of effort to learn the basics of LC, and you simply must, because you will never be able to ask enough questions to make even a simple project work the way you want to. Dictionary, tutorials, user guide. These are fairly accessible and useful. Practice a lot.

Craig