extract element with itemDelimiter

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

Post Reply
problème
Posts: 77
Joined: Fri Oct 23, 2015 12:03 am

extract element with itemDelimiter

Post by problème » Fri Dec 04, 2015 2:55 pm

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

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: extract element with itemDelimiter

Post by dunbarx » Fri Dec 04, 2015 3:17 pm

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

problème
Posts: 77
Joined: Fri Oct 23, 2015 12:03 am

Re: extract element with itemDelimiter

Post by problème » Fri Dec 04, 2015 5:10 pm

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

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

Re: extract element with itemDelimiter

Post by Klaus » Fri Dec 04, 2015 5:44 pm

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! 8)

problème
Posts: 77
Joined: Fri Oct 23, 2015 12:03 am

Re: extract element with itemDelimiter

Post by problème » Sat Dec 05, 2015 12:54 am

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
Last edited by problème on Sat Dec 05, 2015 7:42 pm, edited 2 times in total.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: extract element with itemDelimiter

Post by dunbarx » Sat Dec 05, 2015 6:29 am

Probleme.

"Into", not "to".

Craig

problème
Posts: 77
Joined: Fri Oct 23, 2015 12:03 am

Re: extract element with itemDelimiter

Post by problème » Sat Dec 05, 2015 7:43 pm

i did a careless mistake thanks for the helps

Post Reply