Page 1 of 1
extract element with itemDelimiter
Posted: Fri Dec 04, 2015 2:55 pm
by problème
Hello,
i have a variable that contain :
word1:w1
word2:w2
i would know how to extract w1 and w2 , i think i have to use " set the itemDelimiter to colon " but i can't understand how to use it after.
(i will put w1 and w2 into a field "f1" and "f2"
Code: Select all
put the num of lines of myVariable into nbLigne
repeat with ligne=1 to nbLigne
...
put ... into field ("f"& ligne)
end repeat
Re: extract element with itemDelimiter
Posted: Fri Dec 04, 2015 3:17 pm
by dunbarx
Hi.
If you had your data in a variable "yourVar":
Code: Select all
set the itemDel to ":"
repeat with y = 1 to the number of lines of yourVar
put item 2 of line y of it into field ("F" & y)
end repeat
Craig Newman
Re: extract element with itemDelimiter
Posted: Fri Dec 04, 2015 5:10 pm
by problème
At the line
put item 2 of line y of it into field ("F" & y) when i use "it" there are nothing in the fields, i remplaced by "yourVar" and it's work correctly.
And if i want put news words in place of "word1", "word2" into myVariable
Code: Select all
set the itemDel to ":"
repeat with y = 1 to the number of lines of yourVar
put field ("f"& y) into (item 2 of line y of yourVar)
end repeat
Re: extract element with itemDelimiter
Posted: Fri Dec 04, 2015 5:44 pm
by Klaus
problème wrote:At the line put item 2 of line y of it into field ("F" & y) when i use "it" there are nothing in the fields, i remplaced by "yourVar" and it's work correctly.
Yes, we sometimes add some tiny, but rather obvious errors to test you attention!

Re: extract element with itemDelimiter
Posted: Sat Dec 05, 2015 12:54 am
by problème
ok ^^ , thanks for the helps
for my another problem i do this
Code: Select all
repeat with y = 1 to 5
put ( "word"& y & ": " & "newWord" & y) & cr to myVariable
end repeat
Re: extract element with itemDelimiter
Posted: Sat Dec 05, 2015 6:29 am
by dunbarx
Probleme.
"Into", not "to".
Craig
Re: extract element with itemDelimiter
Posted: Sat Dec 05, 2015 7:43 pm
by problème
i did a careless mistake thanks for the helps