niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Not Unix » VMS
DCL: IF and .AND. logic
Post new topic   Reply to topic Page 1 of 2 [22 Posts] View previous topic :: View next topic
Goto page:  1, 2 Next
Author Message
David J. Dachtera
*nix forums Guru Wannabe


Joined: 21 Mar 2006
Posts: 197

PostPosted: Wed Jun 07, 2006 1:59 am    Post subject: Re: DCL: IF and .AND. logic Reply with quote

JF Mezei wrote:
Quote:

$A = 2
$B = 3
$ IF (A .AND. B) THEN WRITE SYS$OUTPUT "Chocolate" ! writes nothing

$ IF (A .AND. B) .ne. 0 then WRITE SYS$OUTPUT "Rasberry" ! writes "Rasberry"

$ IF .NOT. (A .AND. B) then WRITE SYS$OUTPUT "Rasberry"

....will do the same.

--
David J Dachtera
dba DJE Systems
http://www.djesys.com/

Unofficial OpenVMS Marketing Home Page
http://www.djesys.com/vms/market/

Unofficial Affordable OpenVMS Home Page:
http://www.djesys.com/vms/soho/

Unofficial OpenVMS-IA32 Home Page:
http://www.djesys.com/vms/ia32/

Unofficial OpenVMS Hobbyist Support Page:
http://www.djesys.com/vms/support/
Back to top
Paul Sture
*nix forums Guru


Joined: 12 Feb 2005
Posts: 357

PostPosted: Fri Jun 02, 2006 10:52 am    Post subject: Re: DCL: IF and .AND. logic Reply with quote

JF Mezei wrote:
Quote:
Paul Sture wrote:

In DCL, I personally prefer CALL to GOSUB, as you have to declare your
subroutine formally with



CALL has a major difference from GOSUB: the subroutine does not, by
default, have the ability to modify local symbols defined in your main
DCL code. I *think* this can be overriden with a SET SYMBOL/SCOPE but am
not sure.

But I'm well aware of that fact. Indeed I _want_ to throw away any
temporary variables created in a subroutine, and if I copy a given
subroutine into another procedure*, I _don't_ want it potentially
stamping over any variables in that.

* From a maintenance point of view, it is arguably better to save the
subrouting as another command procedure.
Back to top
Paul Sture
*nix forums Guru


Joined: 12 Feb 2005
Posts: 357

PostPosted: Fri Jun 02, 2006 10:43 am    Post subject: Re: DCL: IF and .AND. logic Reply with quote

Dave Froble wrote:
Quote:
Paul Sture wrote:

$ gosub lunch
$ if $status .eq. too_much_spaghetti then goto sleep


Don't you mean GOSUB SLEEP? You do plan on waking, right? :-)

Of course, but it just read better Smile
Back to top
Paul Sture
*nix forums Guru


Joined: 12 Feb 2005
Posts: 357

PostPosted: Fri Jun 02, 2006 10:37 am    Post subject: Re: DCL: IF and .AND. logic Reply with quote

JF Mezei wrote:
Quote:
Michael Unger wrote:

being an implicite "ENDSUBROUTINE") you get a new procedure level when
it gets executed -- making it easier to manage the "locality" of
symbols.



Au contraire. It makes for much less obvious management of symbols
because when searching for all occurances of a symbol, you will not know
if that symbol is within a subnroutine or not unless you have a really
big window and see that it is within a subroutine code.


On that subject I like to document input and output symbols in comments
at the beginning of a subroutine; subroutine headers will show up in
such a search.

Quote:
Having a new set of local symbols is a neat concept for DCL, but from my
point of view, it causes more grief than harm since the subroutine
cannot modify mainline symbols unless the symbol(s) you modify are not
only declared globally, but there is also no local declarations.


It's simply a matter of discipline, which I happen to like when
programming Smile
Back to top
JF Mezei
*nix forums Guru


Joined: 21 Jul 2005
Posts: 2556

PostPosted: Thu Jun 01, 2006 7:12 pm    Post subject: Re: DCL: IF and .AND. logic Reply with quote

Michael Unger wrote:
Quote:
being an implicite "ENDSUBROUTINE") you get a new procedure level when
it gets executed -- making it easier to manage the "locality" of
symbols.


Au contraire. It makes for much less obvious management of symbols
because when searching for all occurances of a symbol, you will not know
if that symbol is within a subnroutine or not unless you have a really
big window and see that it is within a subroutine code.

When you look at C subroutines, you alwasy have explicit declarations
"or local symbols" within a subroutine. This is not the case with DCL,
and the use of a SET SYMBOL/SCOPE elsewhere in the DCL program can
completely change the behaviour of your symbols.

Having a new set of local symbols is a neat concept for DCL, but from my
point of view, it causes more grief than harm since the subroutine
cannot modify mainline symbols unless the symbol(s) you modify are not
only declared globally, but there is also no local declarations.

$A = 1
..... <lots of lines of code>
$A == 2
$write sys$output "The value of a is ''A'"

The result will show a value of 1
Back to top
JF Mezei
*nix forums Guru


Joined: 21 Jul 2005
Posts: 2556

PostPosted: Thu Jun 01, 2006 6:33 pm    Post subject: Re: DCL: IF and .AND. logic Reply with quote

Paul Sture wrote:
Quote:
In DCL, I personally prefer CALL to GOSUB, as you have to declare your
subroutine formally with


CALL has a major difference from GOSUB: the subroutine does not, by
default, have the ability to modify local symbols defined in your main
DCL code. I *think* this can be overriden with a SET SYMBOL/SCOPE but am
not sure.
Back to top
Dave Froble
*nix forums Guru


Joined: 21 Jul 2005
Posts: 1172

PostPosted: Thu Jun 01, 2006 5:57 pm    Post subject: Re: DCL: IF and .AND. logic Reply with quote

Paul Sture wrote:
Quote:
Dave Froble wrote:
Doug Phillips wrote:

Dave Froble wrote:

Michael Unger wrote:

On 2006-05-30 18:47, "Hoff Hoffman" wrote:

[...]

Run-time computed goto operations -- one of the reasons why it
would
be comparatively "fun" to write a compiler for DCL -- are available:

$ GOTO LABEL_'severity'

I don't like "GOTO" at all -- it is much simpler to "go back" using
"GOSUB" and "RETURN" or "CALL" and "EXIT" (or even "EXIT
status-value>".

[...]

Michael

And next we'll have someone wanting to get rid of the BRANCH
instruction
in assembler.


Uh Oh. I smell another religious war, and here I was just about to
GOSUB lunch ;-)


From which I assume you plan to RETURN. :-)

LOL

$ gosub lunch
$ if $status .eq. too_much_spaghetti then goto sleep

Don't you mean GOSUB SLEEP? You do plan on waking, right? :-)

Quote:
The point is, any instruction can be misused. Don't blame GOTO when
some idiot uses it to write practically unreadable code. If there was
no GOTO, he'd find some other way to screw up.

I knew a guy that was so intent on writing 'structured' code that he
used GOSUB to GOTO the exit part of a program.


I've seen that, but also instances where such coding has lead to
recursive calls causing the program to blow up (not necessarily in DCL).

In DCL, I personally prefer CALL to GOSUB, as you have to declare your
subroutine formally with

$label: SUBROUTINE

...

$ENDSUBROUTINE

Compare the results of HELP CALL EXAMPLE and HELP GOSUB EXAMPLE.

And anybody that has written any assembler code understands that the
various forms of BRANCH is how it's all done regardless of HLL
implementations.


True.


--
David Froble Tel: 724-529-0450
Dave Froble Enterprises, Inc. E-Mail: davef@tsoft-inc.com
DFE Ultralights, Inc.
170 Grimplin Road
Vanderbilt, PA 15486
Back to top
Michael Unger
*nix forums Guru Wannabe


Joined: 01 Jun 2005
Posts: 109

PostPosted: Thu Jun 01, 2006 3:46 pm    Post subject: Re: DCL: IF and .AND. logic Reply with quote

On 2006-06-01 11:43, "Paul Sture" wrote:

Quote:
[...]

In DCL, I personally prefer CALL to GOSUB, as you have to declare your
^^^^^^^^^^^^^^^^^^^^
subroutine formally with

$label: SUBROUTINE

....

$ENDSUBROUTINE

Compare the results of HELP CALL EXAMPLE and HELP GOSUB EXAMPLE.

[...]

In addition to the formal declaration needed for a subroutine ("EXIT"
being an implicite "ENDSUBROUTINE") you get a new procedure level when
it gets executed -- making it easier to manage the "locality" of
symbols. (If you have more of them than just a few hundreds ... ;-)

Michael

--
Real names enhance the probability of getting real answers.
My e-mail account at DECUS Munich is no longer valid.
Back to top
Paul Sture
*nix forums Guru


Joined: 12 Feb 2005
Posts: 357

PostPosted: Thu Jun 01, 2006 9:43 am    Post subject: Re: DCL: IF and .AND. logic Reply with quote

Dave Froble wrote:
Quote:
Doug Phillips wrote:

Dave Froble wrote:

Michael Unger wrote:

On 2006-05-30 18:47, "Hoff Hoffman" wrote:

[...]

Run-time computed goto operations -- one of the reasons why it
would
be comparatively "fun" to write a compiler for DCL -- are available:

$ GOTO LABEL_'severity'

I don't like "GOTO" at all -- it is much simpler to "go back" using
"GOSUB" and "RETURN" or "CALL" and "EXIT" (or even "EXIT
status-value>".

[...]

Michael

And next we'll have someone wanting to get rid of the BRANCH instruction
in assembler.


Uh Oh. I smell another religious war, and here I was just about to
GOSUB lunch ;-)


From which I assume you plan to RETURN. Smile

LOL

$ gosub lunch
$ if $status .eq. too_much_spaghetti then goto sleep

Quote:

The point is, any instruction can be misused. Don't blame GOTO when
some idiot uses it to write practically unreadable code. If there was
no GOTO, he'd find some other way to screw up.

I knew a guy that was so intent on writing 'structured' code that he
used GOSUB to GOTO the exit part of a program.


I've seen that, but also instances where such coding has lead to
recursive calls causing the program to blow up (not necessarily in DCL).

In DCL, I personally prefer CALL to GOSUB, as you have to declare your
subroutine formally with

$label: SUBROUTINE

....

$ENDSUBROUTINE

Compare the results of HELP CALL EXAMPLE and HELP GOSUB EXAMPLE.

Quote:
And anybody that has written any assembler code understands that the
various forms of BRANCH is how it's all done regardless of HLL
implementations.


True.
Back to top
Dave Froble
*nix forums Guru


Joined: 21 Jul 2005
Posts: 1172

PostPosted: Thu Jun 01, 2006 2:23 am    Post subject: Re: DCL: IF and .AND. logic Reply with quote

Doug Phillips wrote:
Quote:
Dave Froble wrote:
Michael Unger wrote:
On 2006-05-30 18:47, "Hoff Hoffman" wrote:

[...]

Run-time computed goto operations -- one of the reasons why it would
be comparatively "fun" to write a compiler for DCL -- are available:

$ GOTO LABEL_'severity'
I don't like "GOTO" at all -- it is much simpler to "go back" using
"GOSUB" and "RETURN" or "CALL" and "EXIT" (or even "EXIT <status-value>".

[...]
Michael

And next we'll have someone wanting to get rid of the BRANCH instruction
in assembler.


Uh Oh. I smell another religious war, and here I was just about to
GOSUB lunch ;-)


From which I assume you plan to RETURN. :-)

The point is, any instruction can be misused. Don't blame GOTO when
some idiot uses it to write practically unreadable code. If there was
no GOTO, he'd find some other way to screw up.

I knew a guy that was so intent on writing 'structured' code that he
used GOSUB to GOTO the exit part of a program.

And anybody that has written any assembler code understands that the
various forms of BRANCH is how it's all done regardless of HLL
implementations.

--
David Froble Tel: 724-529-0450
Dave Froble Enterprises, Inc. E-Mail: davef@tsoft-inc.com
DFE Ultralights, Inc.
170 Grimplin Road
Vanderbilt, PA 15486
Back to top
dphill46@netscape.net
*nix forums Guru Wannabe


Joined: 20 Sep 2005
Posts: 100

PostPosted: Wed May 31, 2006 4:56 pm    Post subject: Re: DCL: IF and .AND. logic Reply with quote

Dave Froble wrote:
Quote:
Michael Unger wrote:
On 2006-05-30 18:47, "Hoff Hoffman" wrote:

[...]

Run-time computed goto operations -- one of the reasons why it would
be comparatively "fun" to write a compiler for DCL -- are available:

$ GOTO LABEL_'severity'

I don't like "GOTO" at all -- it is much simpler to "go back" using
"GOSUB" and "RETURN" or "CALL" and "EXIT" (or even "EXIT <status-value>".

[...]

Michael


And next we'll have someone wanting to get rid of the BRANCH instruction
in assembler.


Uh Oh. I smell another religious war, and here I was just about to
GOSUB lunch Wink
Back to top
Dave Froble
*nix forums Guru


Joined: 21 Jul 2005
Posts: 1172

PostPosted: Wed May 31, 2006 4:40 pm    Post subject: Re: DCL: IF and .AND. logic Reply with quote

Michael Unger wrote:
Quote:
On 2006-05-30 18:47, "Hoff Hoffman" wrote:

[...]

Run-time computed goto operations -- one of the reasons why it would
be comparatively "fun" to write a compiler for DCL -- are available:

$ GOTO LABEL_'severity'

I don't like "GOTO" at all -- it is much simpler to "go back" using
"GOSUB" and "RETURN" or "CALL" and "EXIT" (or even "EXIT <status-value>".

[...]

Michael


And next we'll have someone wanting to get rid of the BRANCH instruction
in assembler.

--
David Froble Tel: 724-529-0450
Dave Froble Enterprises, Inc. E-Mail: davef@tsoft-inc.com
DFE Ultralights, Inc.
170 Grimplin Road
Vanderbilt, PA 15486
Back to top
Paul Sture
*nix forums Guru


Joined: 12 Feb 2005
Posts: 357

PostPosted: Wed May 31, 2006 1:28 am    Post subject: Re: DCL: IF and .AND. logic Reply with quote

Michael Unger wrote:
Quote:
On 2006-05-30 18:47, "Hoff Hoffman" wrote:


[...]

Run-time computed goto operations -- one of the reasons why it would
be comparatively "fun" to write a compiler for DCL -- are available:

$ GOTO LABEL_'severity'


I don't like "GOTO" at all -- it is much simpler to "go back" using
"GOSUB" and "RETURN" or "CALL" and "EXIT" (or even "EXIT <status-value>".


But before GOSUB, CALL etc existed (prior to V4.0 ?), one way of using a
common piece of code was something like:

$ return_label = "A100"
$ goto common_code
$A100:

....

$common_code:

.... do whatever ...

$ goto 'return_label'
Back to top
Michael Unger
*nix forums Guru Wannabe


Joined: 01 Jun 2005
Posts: 109

PostPosted: Tue May 30, 2006 8:43 pm    Post subject: Re: DCL: IF and .AND. logic Reply with quote

On 2006-05-30 18:47, "Hoff Hoffman" wrote:

Quote:
[...]

Run-time computed goto operations -- one of the reasons why it would
be comparatively "fun" to write a compiler for DCL -- are available:

$ GOTO LABEL_'severity'

I don't like "GOTO" at all -- it is much simpler to "go back" using
"GOSUB" and "RETURN" or "CALL" and "EXIT" (or even "EXIT <status-value>".

Quote:
[...]

Michael

--
Real names enhance the probability of getting real answers.
My e-mail account at DECUS Munich is no longer valid.
Back to top
Michael Unger
*nix forums Guru Wannabe


Joined: 01 Jun 2005
Posts: 109

PostPosted: Tue May 30, 2006 7:17 pm    Post subject: Re: DCL: IF and .AND. logic Reply with quote

On 2006-05-29 23:01, "Norman Lastovica" wrote:

Quote:
in this case, I believe that you could just use
the "built-in" $SEVERITY symbol.

If *only* the severity level is to be checked -- then yes. But in most
cases it is desirable to get more detailled information if "something
went wrong" and therefore $STATUS has to be saved before.

Quote:
Michael Unger wrote:

[...]

I'd prefer a construct like:

$ status = $STATUS
^^^^^^^^^^^^^^^^^^
$ severity = status .AND. 7
$ IF severity .EQ. 0 THEN WRITE SYS$OUTPUT ...
$ IF severity .EQ. 1 THEN ...
$ ...

Michael

--
Real names enhance the probability of getting real answers.
My e-mail account at DECUS Munich is no longer valid.
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 2 [22 Posts] Goto page:  1, 2 Next
View previous topic :: View next topic
The time now is Fri Jan 09, 2009 6:05 am | All times are GMT
navigation Forum index » Not Unix » VMS
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts shortcircuit logic in plpsql Joseph Shraibman PostgreSQL 1 Wed Jul 19, 2006 3:12 am
No new posts Parsing data file, need help with the logic guser@packetstorm.org Perl 9 Tue Jun 27, 2006 12:56 pm
No new posts need help with prog. logic Jim M Perl 9 Sun May 28, 2006 3:08 pm
No new posts I need a mini "logic interpreter" Papa Legba PHP 18 Fri May 19, 2006 9:34 am
No new posts problems with retry logic Pavel Gulchouck Exim 5 Thu May 04, 2006 10:32 pm

Myspace Images | 0 Credit Cards | Guitar Lesson | Advertising | Deaf
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.3230s ][ Queries: 16 (0.1864s) ][ GZIP on - Debug on ]