Sarah,

Aren't there possible issues if one changes the contents of the control variable inside a "repeat for each" structure? For repeat for each to work in this case wouldn't one need to make a copy of the control variable for the repeat & make changes to the original?:

on fillBlanks variableList
  put 0 into lineNumber
  get variableList
  repeat for each line theLine in it
    add 1 to x
    if theLine is empty then put [whatEver] into line x of variableList
  end repeat
end fillBlanks

Yes Rob, that is a problem, so if you have a closer look at my script :-) you'll see that I use the contents of the original control variable to build a completely new variable to avoid this problem. In my script (which I have inserted below) "variable" is the name of the original variable used for the control loop. The contents of it, with something else is a line is empty, are used to build up "newVariable". The original "variable" is never changed at all. Your solution does things the other way around but both are valid ways around the potential problem with "repeat for each" loops. BTW as this is purely a demonstrator script, it has no way of actually getting any data in or out - I leave that up to the individual user :-)


on newAddNew
  put empty into newVariable
  repeat for each line L in variable
    if L is empty then
      -- insert the new data in place of the empty line
      put newData & cr after newVariable
    else
      put L & cr after newVariable
    end if
  end repeat
  delete last line of newVariable  -- extra cr
end newAddNew

Cheers,
Sarah

_______________________________________________
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to