Extracting Data From A Tab Delimited String

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
warrenk
Posts: 110
Joined: Sun Sep 21, 2008 5:39 am

Extracting Data From A Tab Delimited String

Post by warrenk » Thu Nov 06, 2008 9:36 pm

I have a string that is separated by tabs. Is there any way to extract the data between tabs? I can't use the word command as there are spaces in my data.

example:
tHilitedText Contains...
name <tab> address 1 <tab> address 2

When I try the following, it only selects data up until a space is reached. I want to select until the tab is reached.

put word 1 of tHilitedText into tName
put word 2 of tHilitedText into tAddress1
put word 3 of tHilitedText into tAddress2

Thanks!
Warren

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Thu Nov 06, 2008 10:03 pm

Code: Select all

set the itemDelimiter to tab
put item 1 of tHilitedText into tName 
put item 2 of tHilitedText into tAddress1 
put item 3 of tHilitedText into tAddress2 
should do the trick

You can "set the itemDelimiter to" very many things, to make your own separators.

warrenk
Posts: 110
Joined: Sun Sep 21, 2008 5:39 am

Post by warrenk » Thu Nov 06, 2008 10:16 pm

SparkOut,

Thanks for helping me out again!!! Appreciate it!

Warren

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Thu Nov 06, 2008 10:23 pm

No problem.
Just for info, note that the itemDelimiter is a local property and will reset itself to comma at the end of each handler.

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Thu Nov 06, 2008 10:25 pm

Also here http://support.runrev.com/scriptingconferences/ you will find some useful info, topic 8 and 16 deal with manipulating text.

billworld
Posts: 188
Joined: Sat Oct 25, 2008 12:32 am

Post by billworld » Fri Nov 07, 2008 1:44 am

Awesome! I was looking to do the same thing today. Thanks!
SparkOut wrote:

Code: Select all

set the itemDelimiter to tab
put item 1 of tHilitedText into tName 
put item 2 of tHilitedText into tAddress1 
put item 3 of tHilitedText into tAddress2 
should do the trick

You can "set the itemDelimiter to" very many things, to make your own separators.

Post Reply