Page 2 of 2
Re: the text I want
Posted: Sun Jun 01, 2014 5:33 am
by robm80
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
Re: the text I want
Posted: Sun Jun 01, 2014 5:44 am
by Simon
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
Re: the text I want
Posted: Sun Jun 01, 2014 6:30 am
by robm80
EUREKA
I changed the itemdel to ";" and that's all.
Script by Klaus!!!
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"
Re: the text I want
Posted: Sun Jun 01, 2014 11:26 am
by Klaus
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