Where is my error ?

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
atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Where is my error ?

Post by atout66 » Fri Mar 14, 2014 10:52 am

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.
Discovering LiveCode Community 6.5.2.

Thierry
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 875
Joined: Wed Nov 22, 2006 3:42 pm

Re: Where is my error ?

Post by Thierry » Fri Mar 14, 2014 11:18 am

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
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Re: Where is my error ?

Post by atout66 » Fri Mar 14, 2014 11:33 am

Oh! thanks Thierry for your help. Work great.
I better understand now the uses of variables inside the repeat loop :wink: .
Discovering LiveCode Community 6.5.2.

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Re: Where is my error ?

Post by atout66 » Sun Mar 23, 2014 11:50 am

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.
Discovering LiveCode Community 6.5.2.

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

Re: Where is my error ?

Post by Klaus » Sun Mar 23, 2014 3:33 pm

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

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

Re: Where is my error ?

Post by dunbarx » Sun Mar 23, 2014 4:06 pm

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

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Re: Where is my error ?

Post by atout66 » Sun Mar 23, 2014 6:16 pm

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:
Discovering LiveCode Community 6.5.2.

Post Reply