Calling Subroutines Multiple Times


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2007
    Posts
    21

    Question Calling Subroutines Multiple Times

    Hey Guys,

    Right now when I want to call the same subroutine 50 times subsequently I do the following code.

    Start:
    GOSUB GoForward
    x=x+1
    IF x>49 THEN
    GOSUB Stop
    ELSE
    GOTO Start
    ENDIF

    Any easier way to do this?

    Thanks,
    Eric

  2. #2
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    As long as i've interpreted your code correctly, this will do the same thing:

    Code:
    for x=0 to 49
        GOSUB GoForward
    next x
    GOSUB Stop
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  3. #3
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Code:
    <font color="#000000">X = <font color="#FF0000"><b>0
    </b></font><font color="#000080"><b>WHILE </b></font>X &lt; <font color="#FF0000"><b>50
     </b></font><font color="#000080"><b>GOSUB </b></font>GoForward
     X = X + <font color="#FF0000"><b>1
    </b></font><font color="#000080"><b>WEND
    
    GOSUB </b></font>SubStop  <font color="#000080"><i>' Stop is reserved word, use something else; like SubStop.
    </i></font>
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

Similar Threads

  1. Multiple PICS from Same Crystal?
    By WOZZY-2010 in forum General
    Replies: 2
    Last Post: - 6th February 2010, 15:18
  2. Multiple RETURNS within a single subroutine
    By BrianT in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 21st June 2009, 16:43
  3. 16F628A - Stops if release power switch.
    By dene12 in forum General
    Replies: 16
    Last Post: - 14th February 2009, 07:57
  4. Multiple IR LEDs from 1 port using transistor
    By belpe123 in forum General
    Replies: 3
    Last Post: - 20th May 2005, 22:07
  5. Using Multiple EEPROMs
    By Tom Gonser in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 27th March 2005, 07:37

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts