Stuart,

 

A GOTO out of a WHILE/ENDHWILE is also not a good idea, IMHO, especially if
it is an optimized WHILE loop.  I use the same technique - set a variable to
the value of a target label, BREAK out of the WHILE and then GOTO &vlabel.

 

A GOTO in an IF/ENDIF is perfectly acceptable.  

 

As a side note, I also learned a long time ago (back in the 3.x / 4.x days)
that one should not RUN other command files from within a SWITCH or WHILE.
The trouble here was that R:BASE wouldn't always be able to 'RETURN' to the
proper place.  I think it was probably a memory allocation issue - this was
DOS, after all.  Windows may handle these situations better, but I still
avoid the practice.

 

My guiding principle here is to give R:BASE the opportunity to close the
program control structure (SWITCH or WHILE) before I go shooting off
somewhere else.  IF/ENDIFs, even nested several levels deep, do not suffer
from the same issues.

 

Emmitt Dove

Manager, DairyPak Business Systems

Evergreen Packaging, Inc.

[EMAIL PROTECTED]

[EMAIL PROTECTED]

(203) 643-8022

 

From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Stuart Cohen
Sent: Tuesday, January 22, 2008 2:42 PM
To: RBASE-L Mailing List
Subject: [RBASE-L] - RE: Two eyes are not good enough

 

Emmitt, Sami and Alastair:

I very much appreciate your comments regarding GOTO commands within SWITCH
blocks.  During the long weekend, I was pondering over your comments
regarding why GOTO commands could be a problem within SWITCH blocks,
especially since I have not had a problem with this situation.........yet.
Then it dawned on me!  The GOTO statement would skip over the BREAK and
ENDSW statements and can thus confuse the computer which is looking for
these statements to close the block.  It also dawned on me that IF blocks
have corresponding ENDIF statements to close them and (though I have never
put a GOTO command in one) WHILE loops have corresponding ENDWHILE commands
to close them.  Does this mean that a programmer should not put GOTO
statements within IF Blocks and WHILE loops?

Once again, thank you very much!

Stuart J. Cohen, Ph.D.
Major, Medical Service Corps
Research Specialist
Walter Reed Army Medical Center
National Disaster Medical System Federal Coordinating Center
Phone: 202-782-3636
Cell: 301-514-3975
Fax: 202-782-4360
E-mail: [EMAIL PROTECTED]

 

 

Emmitt Dove wrote: 

Stuart,

 

To pick up on Albert and Sami's observations about the GOTO from a switch
block, here is how I handle that:

 

SET VAR vlabel TEXT = 'somelabel'

SWITCH (.vwhatever)

  CASE 1

   { Some condition exists }

   SET VAR vlabel = 'thisotherlabel'

    BREAK

  CASE 2

    {a different condition exists}

    SET VAR vlabel = 'yetanotherlabel'

  DEFAULT

    BREAK

ENDSW

GOTO &vlabel

 

Emmitt Dove

Manager, DairyPak Business Systems

Blue Ridge Paper Products, Inc.

[EMAIL PROTECTED]

[EMAIL PROTECTED]

(203) 643-8022

 


Sami Aaron wrote: 

Stuart -

 

I see two possibilities:

 

 "IF variable = NULL  THEN" should be    "IF variable IS NULL THEN"

Within a SWITCH block, you should issue "BREAK" instead of using "GOTO
TheEnd".. The break will drop the programming call down to the next line
after the ENDSW line.

Sami

 

____________________________

Sami Aaron

Software Management Specialists

913-915-1971

[EMAIL PROTECTED]

 

 

 

Alastair Burr wrote: 

I may be completely wrong but I thought that GOTOs in SWITCH statements were
something to be avoided. Maybe it's that which is not working?

 

Regards,

Alastair.

 

 

Reply via email to