Page 1 of 1

Repeat loop and filling a list field

Posted: Mon Aug 10, 2009 5:11 am
by Glenn Boyce
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

Repeat loop and filling a list field

Posted: Mon Aug 10, 2009 5:46 am
by edljr
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

Empty doesn't seem to do the trick

Posted: Mon Aug 10, 2009 9:39 pm
by Glenn Boyce
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