itemDel

Yves Coppé yvescoppe at skynet.be
Wed Jul 31 07:11:00 EDT 2002


>On Wednesday, July 31, 2002, at 08:42 , Yves Coppé wrote:
>
>>Hi,
>>
>>is it possible to write a function which should extract an item of 
>>a list BUT the itemDel should be, NOT one Char, but a charset of 3 
>>chars !
>
>Yves
>
>Is the real problem here the fact that you _must_ use the 
>three-character delimiter? Otherwise you could just take a copy of 
>the data and use
>   replace "*$*" with comma in dataCopy
>then access items as usual.
>
>However, while the documentation says "The itemDelimiter is a single 
>character" you can in fact set it to a string as long as you capture 
>a little problem in the result.
>
>For example, if your delimiter were "BOO" and the string Fred 
>contains "OneBOOTwoBOOThreeBOOFour" then the code
>   set itemDelimiter to "BOO"
>   put char 3 to -1 of item 2 of Fred
>produces "Two", as you desire.
>Note that I stripped the first two characters in the answer. The 
>item separates at the first character of the string set as the 
>itemDelimiter. If you just said "put item 2 of Fred" then it would 
>return "OOTwo"
>
>Two issues though:
>1. As it is undocumented, it may not be supported in a future 
>version unless RunRev says it is OK (...?)
>2. Your example string "*$*" did not work when I tried it, possibly 
>because it is being treated as a regular expression after the first 
>character (speculation).
>
>So, the first method, using <replace> works most comfortably.
>
>Hope one of these works for you.
>


I think your way is good :
replace a charset with one char and use this one char as delim
for the speed, I will follow the tip of Jan who makes afterwards an 
array using the split command.

So a good example of the work of the user-list : a little bit of each 
answer gives a good code.

thank you for the tips
-- 
Greetings.

Yves COPPE

Email : yvescoppe at skynet.be



More information about the Use-livecode mailing list