Page 1 of 1

Where is my error ?

Posted: Fri Mar 14, 2014 10:52 am
by atout66
Hi to all,
Could you tell me what's wrong with my script below:

Code: Select all

get URL "http://fr.wiktionary.org/wiki/accompagner" -- we read the source code
   repeat with x = 1 to the number of lines of IT -- we want to place an index number in front of each line code
      put line x of IT into tLaLigne -- we isolate each line first
      set the Text of line x of IT to x&&":"&&tLaLigne -- we can't place the index number; this line makes an ERROR; why ?
   end repeat
Thanks for your help.

Re: Where is my error ?

Posted: Fri Mar 14, 2014 11:18 am
by Thierry
Hi,

a modified version of your script..

Code: Select all

   put URL "http://fr.wiktionary.org/wiki/accompagner" into Tsource
   put empty into Toutput
   repeat with x = 1 to the number of lines of Tsource
        -- we want to place an index number in front of each line code
        put x &":"& line x of Tsource &cr after Toutput
   end repeat
You can check repeat for each line... in the dictionary,
and read the important notice at the end..

HTH,

Thierry

Re: Where is my error ?

Posted: Fri Mar 14, 2014 11:33 am
by atout66
Oh! thanks Thierry for your help. Work great.
I better understand now the uses of variables inside the repeat loop :wink: .

Re: Where is my error ?

Posted: Sun Mar 23, 2014 11:50 am
by atout66
I answer to myself just to say that I found an interresting function in the LiveCode lessons.
For the same result, it use the prefixed function.
You can know more on this page: http://lessons.runrev.com/s/lessons/m/2 ... in-a-field.

Re: Where is my error ?

Posted: Sun Mar 23, 2014 3:33 pm
by Klaus
Bonjour atout66,
set the Text of line x of IT to x&&":"&&tLaLigne -- we can't place the index number; this line makes an ERROR; why ?
the error is that you cannot "set the text of LINE X..."!
You can set the text of a field or button, but not a line in a variable or field, that was the problem.


Best

Klaus

Re: Where is my error ?

Posted: Sun Mar 23, 2014 4:06 pm
by dunbarx
Atout66.

There are two things going on here. Some entities in LC are called "containers". These are fields, variables, the message box and buttons. They "contain" data, and you manage them by;

put yourData into field 3 (or perhaps: get field 3)
put yourData into button "yourButton" (or perhaps: answer button "yourButton)
put yourData into yourVariable (or perhaps: put yourVariable into the message box)

But other entities are "properties", like:

the text of field "yourField"
the height of field "yourField"
the loc of fld "yourField"

You may "set" or "get" those values, but you cannot "put" anything into them. For example, the script of an object is a property of that object. You can change that script, but you have to "set" the property. So if you had this in a variable "newScript":

on mouseUp
beep 3
end mouseUp

You could: set the script of button "yourButton" to newScript, but you cannot: put newScript into the script of button "yourButton".

Takes a little getting used to, but you will soon become an expert,

Craig Newman

Re: Where is my error ?

Posted: Sun Mar 23, 2014 6:16 pm
by atout66
Thanks to all of you for your patience and pedagogy.

I'm in no hurry to become an expert, otherwise I will miss a lot of other things :wink: