Shop OBEX P1 Docs P2 Docs Learn Events
Subroutince/Function newbie question — Parallax Forums

Subroutince/Function newbie question

LuXo12LuXo12 Posts: 31
edited 2008-09-05 15:30 in BASIC Stamp
Hi everyone I am a n00b so I don't know if that would work or if that is even possible

I am trying to use a subroutine several times in a row and I was wondering if I could do some thing like 3 X GoSub_ONOFF

Here is what i mean:

Instead of writing

GoSub_OnOff
GoSub_OnOff
GoSub_OnOff
GoSub_OnOff
GoSub_OnOff

for x number of times could i do something like?

5 x GoSub_OnOff

and get the same result?

Thanks for help

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-09-05 04:05
    No

    You could write
    for i = 1 to 5
      gosub GoSub_OnOff
    next i
    


    where i is declared as a nib or byte.
    Read the PBasic Manual in the chapters on the FOR statement
    and the GOSUB statement.
  • LuXo12LuXo12 Posts: 31
    edited 2008-09-05 15:30
    That makes sense, thank you!
Sign In or Register to comment.