Repeat loop and filling a list field

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Glenn Boyce
Posts: 137
Joined: Thu Jul 24, 2008 11:22 pm

Repeat loop and filling a list field

Post by Glenn Boyce » Mon Aug 10, 2009 5:11 am

I have a repeat loop that is meant to fill a list field from line 1 through to about line 10. Before I start I put "" into the field and for some reason it always starts on line 2 of the field leaving a blank line at the top. I have used the following code

put the number of lines of fld "toolist" into tlines
put ttoolitem into line tlines + 1 of fld "Toolist"
put "" into ttoolitem

Code: Select all


anyone see a problem?

cheers

edljr
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 56
Joined: Sun Oct 26, 2008 6:47 am
Contact:

Repeat loop and filling a list field

Post by edljr » Mon Aug 10, 2009 5:46 am

Glenn,

If you want to clear out a field, the best way (I think) is to use put empty into fld "fieldName" - not sure from your example if you want the entire field cleared.

Here is sample code that clears the field, then populates 10 lines of text.

Code: Select all

on mouseUp
   put empty into fld "toolList"
   repeat with x = 1 to 10
      put "Line Number " & x into line x of fld "toolList"
   end repeat
end mouseUp
HTH,
Ed
--
Ed Lavieri
three19
www.three19.com
--

Glenn Boyce
Posts: 137
Joined: Thu Jul 24, 2008 11:22 pm

Empty doesn't seem to do the trick

Post by Glenn Boyce » Mon Aug 10, 2009 9:39 pm

Hi Ed. tried that and doesn't fix the problem. I've put the whole piece of code below and no doubt there will be a silly little thing that has it starting from the second line in the field when it repeats.

Code: Select all

 put empty into fld "Toolist"
  
  repeat with n=1 to 10
    put item 7+n of gToolsetDetails into tToolNo
    put lineoffset(tToolNo,gtooldata) into tlineNo
    put item 1 of line tlineNo of gtooldata & "," after ttoolitem
    put item 5 of line tlineNo of gtooldata & "," after ttoolitem
    put item 3 of line tlineNo of gtooldata & "," after ttoolitem
    put item 19 of line tlineNo of gtooldata & "," after ttoolitem
    put item 7 of line tlineNo of gtooldata after ttoolitem
    replace comma with tab in ttoolitem
   put the number of lines of fld "toolist" into tlines
    put ttoolitem into line tlines + 1 of fld "Toolist"
    put empty into ttoolitem
    
  end repeat

Post Reply