Announcement

Collapse
No announcement yet.

Exit from sub inside a loop

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Eric Pearson
    replied
    Brian --

    No, not unless you are exiting from your PBMain or WinMain function and thereby closing the entire program. Exiting from SUBs or FUNCTIONs that are "below" the "main" function has no effect on open files.

    -- Eric

    ------------------
    Perfect Sync: Perfect Sync Development Tools
    Email: mailto:[email protected][email protected]</A>



    [This message has been edited by Eric Pearson (edited June 05, 2000).]

    Leave a comment:


  • Brian Reynolds
    replied
    When I EXIT from SUB does it also close any files that may be open?

    Regards,
    Brian.


    ------------------

    Leave a comment:


  • E B Knoppert
    Guest replied
    I decompiled it using HelpDeco.

    Printed it ... and had fun to read..
    The problem is, i can't remember all of it so i need the help



    ------------------

    Leave a comment:


  • Frank Kelley
    Guest replied
    Darn, I wish I had printed manuals to browse!
    Available for $29.95 from PowerBASIC sales department. No offense to the online help, but the printed manual makes it much easier to understand!

    Frank

    ------------------

    Leave a comment:


  • Michael Mattias
    replied

    But i also wish to point out a great PB feature:

    Exit, Exit
    You know, I never knew until now that PB had implemented that in the new compiler (also the variations with 'ITERATE').

    Darn, I wish I had printed manuals to browse!

    MCM

    Leave a comment:


  • Brian Reynolds
    replied
    Thanks for your help. That will solve a few problems for me.
    Regards,
    Brian.


    ------------------

    Leave a comment:


  • E B Knoppert
    Guest replied
    Good question!

    But i also wish to point out a great PB feature:

    Exit, Exit

    This is possible to leave 2 (different) loops..
    Check the help..

    This helped me very well and check out iterate as well.



    ------------------

    Leave a comment:


  • Lance Edmonds
    replied
    It will work fine - you are doing everything perfectly "legally".

    PowerBASIC cleans up the stack frame for the sub/function when execution of the sub/function terminates - this is handled automatically for you, and is one of the benefits of using a high-level language like PowerBASIC. In fact, this type of operation is exactly how the EXIT statement is designed let you to work. All memory used by local variables and arrays are automatically released.

    The only thing you would have to clean up yourself would be GDI objects (brushes, pens, bitmaps, or Device Contexts, etc) or memory allocations that were created with API functions (GlobalAlloc(), etc), rather than native PowerBASIC code.


    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Brian Reynolds
    started a topic Exit from sub inside a loop

    Exit from sub inside a loop

    I need to know if I will cause chaos if I continually exit from a subroutine while in a FOR - NEXT loop or an IF - END IF.

    For example:

    Sub TEST
    FOR b = 1 to 100
    IF b = 50 THEN
    a$ = "Help"
    EXIT SUB
    END IF
    NEXT b
    END SUB

    Will this cause a problem if I continually EXIT from the SUB in the middle of the FOR - NEXT loop or the IF - END IF.

    I hope someone can actually understand what I mean.

    Regards,
    Brian.

Working...
X