Breaking out of for loops


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429

    Default Breaking out of for loops

    Just a quickie. Is it safe to break out of a subroutine when in the middle of a for loop? Or will stacks and things get messed up?

    Example of what i'm talking about:

    Code:
    subroutine:
    FOR n=0 TO 100
        IF n=50 then RETURN
    NEXT n
    RETURN
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    That is OK.

    For-Next loops do not use stack space.

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


    Did you find this post helpful? Yes | No

    Default

    Cool. Thanks Melanie.
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  4. #4
    Join Date
    Oct 2005
    Posts
    74


    Did you find this post helpful? Yes | No

    Default

    Would a While/Wend be more appropriate?

Similar Threads

  1. Breaking through pages in PIC16 Series
    By crematory in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 1st August 2005, 13:49

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