Monte Goulding wrote:
> Sorry folks I should have been more specific and said using existing
> syntax. So the original thing posted is what Iā€™m after at the moment:
> local tIndex
> put 1 into tIndex
> repeat for each line tLine in tLines
>    ā€” code
>    add 1 to tIndex
> end repeat

Except that's wrong. :)

I tend to use 0 as the initial value, and increment at the top of the loop:

  local tIndex
  put 0 into tIndex
  repeat for each line tLine in tLines
      add 1 to tIndex
      ā€” code
  end repeat

I've found two benefits from this habit:

1. (minor) Clearer distinction between unincremented and incremented counter.

2. (major) I can "next repeat" at any point in the block and know that the counter is appropriately updated.

Indeed, it was a runaway loop many years ago that set me know this path.

All this raises a bigger question: can we for now provide some sparse minimums and perhaps consider adding more later if truly needed?

Saves work for you folks, and obviates the need to have what would likely be really long threads here about different coding styles (or whether all possible styles should be supported in Prefs - "Damnation to the dangling 'thens'!" <g>).

 Richard Gaskin
 Fourth World Systems
 Software Design and Development for the Desktop, Mobile, and the Web

use-livecode mailing list
Please visit this url to subscribe, unsubscribe and manage your subscription 

Reply via email to