Sign up on the Revelation Software website to have access to the most current content, and to be able to ask questions and get answers from the Revelation community

At 18 MAR 1999 11:00:30AM Oystein Reigem wrote:

I almost never use the gosub statement, but I need it now. Tell me - is it exactly like a goto? Except that when the execution encounters a return, that brings you back to the statement following the gosub?

If that is so the following way of breaking out of the internal gosub procedure must be valid?:

<code>

    ...main procedure stuff...
    gosub internal_procedure
    ...more main procedure stuff...
    
main_procedure_end:
    ...cleanup...
    return ...
    
internal_procedure:
    ...internal procedure stuff...
    if ...error... then
        /* break */
        goto main_procedure_end
    end
    ...more internal procedure stuff...
    /* normal return from internal procedure */
    return

</code>

- Oystein -


At 18 MAR 1999 11:36AM Ashley Chapman wrote:

Yep,

Thats how I use it.


At 18 MAR 1999 11:37AM Matt Sorrell wrote:

Oystein,

Personally, I would modify your logic as follows (my changes are in CAPS):

…main procedure stuff…

  ERR.FLAG=FALSE$
  gosub internal_procedure
  IF ERR.FLAG=TRUE$ THEN GOTO MAIN_PROCEDURE_END
  ...more main procedure stuff...

main_procedure_end:

  ...cleanup...
  return ...

internal_procedure:

  ...internal procedure stuff...
  if ...error... then
  • /* break */ *goto main_procedure_end
      ERR.FLAG=TRUE$
      RETURN
  end
  ...more internal procedure stuff...
  /* normal return from internal procedure */
  return

To me, this provides better program control and reduces the level of 'spaghettiness' in the code. My mind cringes at the thought of goto'ing out of a gosub. In this fashing, you set an error condition, return from your gosub, and then handle the error condition. Kind of like bubbling an error in VB (sort of, not really, never mind, *grin*).

Matt Sorrell

[email protected]


At 18 MAR 1999 11:46AM Greg James, ISIS, Inc. wrote:

I have seen the Return To statement in old Arev code. I have tried to use it in OpenInsight, but either I'm using it the wrong way or it isn't there.


At 18 MAR 1999 12:16PM Oystein wrote:

Matt,

In principle I agree with you, and normally I'd return a status value like you say. But gosubs are dodgy anyway so I thought I'd go the whole hog.

- Oystein -


At 18 MAR 1999 12:18PM Oystein Reigem wrote:

Ashley,

Thanks.

- Oystein -


At 18 MAR 1999 12:49PM [email protected] - [url=http://www.sprezzatura.com]Sprezzatura Group[/url] wrote:

For whatever reason, this feature was removed from OpenInsight and is not available.

[email protected]

Sprezzatura Group

www.sprezzatura.com_zz.jpg


At 18 MAR 1999 02:22PM [email protected] - [url=http://www.sprezzatura.com]Sprezzatura Group[/url] wrote:

GoSubs are dodgy? And goto's aren't? I don't know if I can code without gosubs, esp. on…gosub…

[email protected]

Sprezzatura Group

www.sprezzatura.com_zz.jpg


At 18 MAR 1999 02:43PM Eric Emu wrote:

What about CHAIN ?

Eric


At 18 MAR 1999 02:47PM [email protected] onmouseover=window.status=why not click here to send me email?;return(true)", [url=http://www.sprezzatura.com" onMouseOver=window.status=Why not click here to visit our web site?';return(true)]Sprezzatura Group[/url] wrote:

That was really cool, Michael doing that funny shuffling dance in the bar, waving his wings about….

[email protected]

Sprezzatura Group

World Leaders in all things RevSoft


At 18 MAR 1999 03:09PM [email protected] wrote:

Sounds like you're pulling mine.

It's still there. In Windoze it's RunLoadNewCancelOldTransferControlEventProg

[email protected]

ourworld.compuserve.com_homepages_garygnu_graphics_show-gnu.jpg


At 18 MAR 1999 06:52PM Eric Emu wrote:

Gary, nice pic.

Was it your idea to have CHAIN statements

automatically precede a FLUSH ?

Cheers,

Eric


At 19 MAR 1999 02:18AM Nick Stevenson wrote:

My few cents worth… We forbid our programmers to use any form of GO TO. I cannot see how you can write a structured program without GOSUBS. It is the most elementary of all flow control verbs.


At 19 MAR 1999 05:09AM Oystein Reigem wrote:

Nick,

My few cents worth… We forbid our programmers to use any form of GO TO.

I'm the only programmer on this project. When I want to use a GOTO I just don't tell my project manager. He's not ever going to notice.

If it can console you I use GOTOs very sparingly, and in a highly disciplined manner. Regard the example in my posting as a rare exception.

I cannot see how you can write a structured program without GOSUBS. It is the most elementary of all flow control verbs.

ON GOSUB used strictly for branching, yes. Except I tend to use CASE out of habit. (I know it's less efficient.)

But I don't really like internal procedures that you "call" with GOSUBs. I prefer to use external functions with parameters and a return value. Also they have a separate variable scope. I don't think I have GOSUBs in more then three out of many hundred Basic+ procedures I have written.

Just my 2 øre…

- Oystein -

View this thread on the forum...

  • third_party_content/community/commentary/forums_nonworks/1159c26682e476d585256738005271c3.txt
  • Last modified: 2024/01/04 21:00
  • by 127.0.0.1