Code Comments
Programming Forum and web based access to our favorite programming groups.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
Post Follow-up to this messageOn 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.
Post Follow-up to this message> 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
Post Follow-up to this message> >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?')
Post Follow-up to this messageMichael 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.
Post Follow-up to this messageHoward 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.
Post Follow-up to this message"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
Post Follow-up to this messageIn 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
Post Follow-up to this messageOliver, 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 > >
Post Follow-up to this message"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
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.