November 21, 2024, 04:26:38 PM

News:

Be sure to checkout our Vixen interfaces in the Library forum -- if you want PC automation at near zero cost, EFX-TEK and Vixen is a great combination of tools.


Nesting FOR/NEXT?

Started by steveo, September 09, 2007, 03:06:03 PM

Previous topic - Next topic

steveo

Jonny,
My man, my ace, my brother from another mother!

Forgive such a nebulous question, but if you were to create a for/next loop, then nest another within it, how would you go about it?

JonnyMac

September 09, 2007, 03:36:23 PM #1 Last Edit: September 10, 2007, 01:52:53 PM by JonnyMac
Easy-peezy -- use two control variables.  This little segment, for example, will flash an LED quickly five times and then pause one second, and do that three times.

Main:
  FOR burst = 1 TO 3
    FOR flashes = 1 TO 5
      HIGH Led
      PAUSE 100
      LOW Led
      PAUSE 100     
    NEXT ' (flashes)
    PAUSE 1000
  NEXT ' (burst)


Note how formatting (indenting, etc.) keeps things organized and easy to follow -- I added comments after each NEXT so you know what's what.
Jon McPhalen
EFX-TEK Hollywood Office

steveo