Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Semantics and syntax of the ADD ... GIVING statement
According to my reference, the syntax for the ADD ... GIVING statement is as
follows ([] means optional, + means 1 or more times, <> means "substitute a
value here")

ADD <identifier or literal>+ [ TO ] <identifier or literal>+ GIVING (
<identifier> [ ROUNDED ] )+

Since the TO keyword is optional, is there a semantic difference between:

ADD 10 27 GIVING foo
and
ADD 10 TO 27 GIVING foo
?

Also, is it a requirement that the ADD ... GIVING statement has at least 2
operands? I.e. is the following valid:

ADD 5 GIVING foo

- Oliver



Report this thread to moderator Post Follow-up to this message
Old Post
Oliver Wong
09-15-05 11:55 PM


Re: Semantics and syntax of the ADD ... GIVING statement
On Thu, 15 Sep 2005 15:05:42 GMT "Oliver Wong" <owong@castortech.com> wrote:

:>According to my reference, the syntax for the ADD ... GIVING statement is 
as
:>follows ([] means optional, + means 1 or more times, <> means "substitute 
a
:>value here")

:>    ADD <identifier or literal>+ [ TO ] <identifier or literal>+ GIVING (
:><identifier> [ ROUNDED ] )+

:>Since the TO keyword is optional, is there a semantic difference between:

:>    ADD 10 27 GIVING foo
:>and
:>    ADD 10 TO 27 GIVING foo
:>?

I believe that they are identical.

:>Also, is it a requirement that the ADD ... GIVING statement has at least 2
:>operands? I.e. is the following valid:

:>    ADD 5 GIVING foo

I believe that two or more operands are required.

--
Binyamin Dissen <bdissen@dissensoftware.com>
http://www.dissensoftware.com

Director, Dissen Software, Bar & Grill - Israel


Should you use the mailblocks package and expect a response from me,
you should preauthorize the dissensoftware.com domain.

I very rarely bother responding to challenge/response systems,
especially those from irresponsible companies.

Report this thread to moderator Post Follow-up to this message
Old Post
Binyamin Dissen
09-15-05 11:55 PM


Re: Semantics and syntax of the ADD ... GIVING statement

> Since the TO keyword is optional, is there a semantic difference between:
>
>     ADD 10 27 GIVING foo
> and
>     ADD 10 TO 27 GIVING foo
> ?

No.

> Also, is it a requirement that the ADD ... GIVING statement has at least 2
> operands?

Yes.  The syntax diagram requires at least two addends.

>I.e. is the following valid:
>
>     ADD 5 GIVING foo


No.

-Chuck Stevens



Report this thread to moderator Post Follow-up to this message
Old Post
Chuck Stevens
09-15-05 11:55 PM


Re: Semantics and syntax of the ADD ... GIVING statement
> >I.e. is the following valid: 

> No.

It's not just invalid, it's silly. Add 5 and what?  Or to what?

('Add 5 to foo' would be valid, however).

MCM
(Damn, wouldn't it be a hoot to actually get a compiler error message
containing the word 'silly?')










Report this thread to moderator Post Follow-up to this message
Old Post
Michael Mattias
09-15-05 11:55 PM


Re: Semantics and syntax of the ADD ... GIVING statement
Michael Mattias wrote: 
> 
>
> It's not just invalid, it's silly. Add 5 and what?  Or to what?
>
> ('Add 5 to foo' would be valid, however).
>
> MCM
> (Damn, wouldn't it be a hoot to actually get a compiler error message
> containing the word 'silly?')

I've had CoBOL programs that added 0 to numbers, to make sure that the
resulting number would be in the correct format.


Report this thread to moderator Post Follow-up to this message
Old Post
Howard Brazee
09-15-05 11:55 PM


Re: Semantics and syntax of the ADD ... GIVING statement
Howard Brazee wrote:
> Michael Mattias wrote: 
>
> I've had CoBOL programs that added 0 to numbers, to make sure that the
> resulting number would be in the correct format.

And I saw one that had:

MOVE X.

I guess for the purpose of getting it out of the way.



Report this thread to moderator Post Follow-up to this message
Old Post
HeyBub
09-15-05 11:55 PM


Re: Semantics and syntax of the ADD ... GIVING statement
"Michael Mattias" <michael.mattias@gte.net> wrote in message
news:sIgWe.1310$D42.34@newssvr19.news.prodigy.com...
> (Damn, wouldn't it be a hoot to actually get a compiler error message
> containing the word 'silly?')

Back in my "Compilers" class in university, one of the warning messages
the compiler I wrote produced was "Why would you ever want to do this?" I
forget the exact details, but it was detecting obscure, useless, but legal
syntax.

- Oliver



Report this thread to moderator Post Follow-up to this message
Old Post
Oliver Wong
09-15-05 11:55 PM


Re: Semantics and syntax of the ADD ... GIVING statement
In article <sIgWe.1310$D42.34@newssvr19.news.prodigy.com>,
Michael Mattias <michael.mattias@gte.net> wrote:

[snip]

>(Damn, wouldn't it be a hoot to actually get a compiler error message
>containing the word 'silly?')

I once mis-coded a SEARCH (or maybe it was a SEARCH ALL) back in the days
of IKFCBL00 so the error read 'EXPECTED WHEN. FOUND 'WHEN'. DELETING UNTIL
NEXT VALID INPUT.'

DD


Report this thread to moderator Post Follow-up to this message
Old Post

09-15-05 11:55 PM


Re: Semantics and syntax of the ADD ... GIVING statement
Oliver,
A couple of "add-on" comments to Chuck's (correct) statement.

1) Looking at BOTH the '85 And '02 Standards, if the identifier-2 / literal-
2
items were in "square brackets" rather than "curli-brackets" this would have
indicated that they were optional.  This distinction is pretty important in
understanding how to read Standard COBOL syntax diagrams.

2) The '85 Standard identifies the (optional) "TO" word in the "giving" form
at
of the ADD statement as a "Substantive change".  Therefore, if you need to
distinguish between '74 and '85 (or later) syntax, this was an EXTENSION if
available in a '74 Standard compiler.  (I know that IBM did allow it, but I
don't know how common it was - as an extension).

--
Bill Klein
wmklein <at> ix.netcom.com
"Chuck Stevens" <charles.stevens@unisys.com> wrote in message
news:dgc3v2$rlq$1@si05.rsvl.unisys.com...
> 
>
> No.
> 
>
> Yes.  The syntax diagram requires at least two addends.
> 
>
>
> No.
>
>    -Chuck Stevens
>
>



Report this thread to moderator Post Follow-up to this message
Old Post
William M. Klein
09-15-05 11:55 PM


Re: Semantics and syntax of the ADD ... GIVING statement
"William M. Klein" <wmklein@nospam.netcom.com> wrote in message
news:EIhWe.20156$R83.14463@fe04.news.easynews.com...

> 2) The '85 Standard identifies the (optional) "TO" word in the "giving"
format
> of the ADD statement as a "Substantive change".  Therefore, if you need to
> distinguish between '74 and '85 (or later) syntax, this was an EXTENSION
if
> available in a '74 Standard compiler.  (I know that IBM did allow it, but
I
> don't know how common it was - as an extension).

I can say with some certainty that the COBOL74 compiler used in the Unisys
MCP environment does not allow both TO and GIVING in the same ADD statement.
I can't address how common this extension was, but I can say that it wasn't
universal.

-Chuck Stevens



Report this thread to moderator Post Follow-up to this message
Old Post
Chuck Stevens
09-15-05 11:55 PM


Sponsored Links




Last Thread Next Thread Next
Pages (3): [1] 2 3 »
Search this forum -> 
Post New Thread

Cobol archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 11:07 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.