the text I want

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

robm80
Posts: 161
Joined: Sat May 03, 2014 7:15 am

Re: the text I want

Post by robm80 » Sun Jun 01, 2014 5:33 am

I hope you understand my problem:put item 5 of line it of field "DB1" of cd "DB"into tData in fact should be Put item 5 and the rest of the line into tData.
For me it did not work and hanged on the fact that the script must work for all kinds of Items 5, that never are the same in items or words.
Furthermore I think stead wordoffset itemoffset should be preferred. I changed that in the script, but again: nope!

Thanks anyway, Rob

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: the text I want

Post by Simon » Sun Jun 01, 2014 5:44 am

Hi Rob,
Again if this is "free text" how will anyone be able to delimit it?
If "tel" could be "phone" and "email" could be "home address" or anything else what application could figure out how to separate the items?

My example worked well on the information you posted first.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

robm80
Posts: 161
Joined: Sat May 03, 2014 7:15 am

Re: the text I want

Post by robm80 » Sun Jun 01, 2014 6:30 am

EUREKA

I changed the itemdel to ";" and that's all.
Script by Klaus!!! :lol:

put item 5 of line tLO of field "DB1" of cd "DB"into tData
set itemdel to ";"
put the num of items of tData into itc
repeat with i = 1 to itc
put item i of tData &cr after tVar
filter tVar without empty
end repeat
put tVar into fld "note"

Klaus
Posts: 14206
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: the text I want

Post by Klaus » Sun Jun 01, 2014 11:26 am

Hi Rob,
robm80 wrote:
...
Here is the same line now with comma's.
4allclients,robmeyer@hetnet.nl,11220076,https://www.4allclients.com, 4AllClients.com? B.V., Opaalstraat 14, 7554 TS Hengelo, 0900-273-8446
...
set itemdel to ","
put item 5 of line tLO of field "DB1" of cd "DB"into tData PROBLEM: item 5 =4AllClients.com? B.V.,
...
it sound like you do not get the point with ITEMS or ITEMS at all, when you describe this as a problem!

Now that line has 8 (EIGHT) items, OK?
So why not take the FIFTH to LAST item of the line?
No need to change the itemdelimiter!

And there are even more ways to do so:

Code: Select all

...
## We can supply a NEGATIVE number, that the engine will count from the end:
## we take item 5 to the last item (item -1) of the line:
put item 5 TO -1 of line tLO of field "DB1" of cd "DB" into tData

## 1. The "natural" approach:
replace "," with CR in tData
put tData into fld "note"

Code: Select all

## 2. The "programming" approach
put the num of items of tData into itc
repeat with i = 1 to itc
   put item i of tData &cr after tVar
   filter tVar without empty
end repeat
put tVar into fld "note"
...
Best

Klaus

Post Reply