Parsing string in an array

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
tasdvl9
Posts: 94
Joined: Fri Dec 06, 2013 3:55 am

Parsing string in an array

Post by tasdvl9 » Wed Feb 26, 2014 9:36 pm

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!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10333
Joined: Wed May 06, 2009 2:28 pm

Re: Parsing string in an array

Post by dunbarx » Wed Feb 26, 2014 9:45 pm

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

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Parsing string in an array

Post by FourthWorld » Wed Feb 26, 2014 9:46 pm

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?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

tasdvl9
Posts: 94
Joined: Fri Dec 06, 2013 3:55 am

Re: Parsing string in an array

Post by tasdvl9 » Wed Feb 26, 2014 9:49 pm

Thanks, Craig!

Much appreciated.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10333
Joined: Wed May 06, 2009 2:28 pm

Re: Parsing string in an array

Post by dunbarx » Wed Feb 26, 2014 9:59 pm

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

Post Reply