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

Passing an invalid date to INTEGER-OF-DATE
What happens in COBOL if you reference the INTEGER-OF-DATE function and
specify an invalid date for the argument?

The 1985 COBOL standard says that anything can happen ("the result of such a
reference is undefined").

I would be interested to know the results for various compilers.  The
question came up during a migration.

Thanks.

Walter



----== Posted via mcse.ms - Unlimited-Uncensored-Secure Usenet News==-
---
http://www.mcse.ms The #1 Newsgroup Service in the World! 120,000+ New
sgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----

Report this thread to moderator Post Follow-up to this message
Old Post
Walter Murray
05-24-05 01:55 PM


Re: Passing an invalid date to INTEGER-OF-DATE
Good to see you participating, Walter!

Unisys MCP COBOL85 gives a zero result, the same as it would give for the
(out-of-bounds) date of 12/31/1600.

For an ISO/IEC 1989:2002-compliant compiler, the user can >>TURN EC-ALL
CHECKING ON, and in that instance, a bad argument value to INTEGER-OF-DATE
woud cause the EC-ARGUMENT-FUNCTION exception condition to be set to exist,
and if no actual handling (generic or specific to the exception) were
provided, the program would be discontinued.

Note that according to the ANSI X3.23-1985 glossary, "integer" values do not
include zero unless the rules for the particular construct so state, which
they don't for either INTEGER-OF-DATE or for DATE-OF-INTEGER.

-Chuck Stevens

"Walter Murray" <wmurray@midtown.net> wrote in message
news:4292ab55$1_2@spool9-west.superfeed.net...
> What happens in COBOL if you reference the INTEGER-OF-DATE function and
> specify an invalid date for the argument?
>
> The 1985 COBOL standard says that anything can happen ("the result of such
a
> reference is undefined").
>
> I would be interested to know the results for various compilers.  The
> question came up during a migration.
>
> Thanks.
>
> Walter
>
>
>
> ----== Posted via mcse.ms - Unlimited-Uncensored-Secure Usenet
News==----
> http://www.mcse.ms The #1 Newsgroup Service in the World! 120,000+
Newsgroups
> ----= East and West-Coast Server Farms - Total Privacy via Encryption
=----



Report this thread to moderator Post Follow-up to this message
Old Post
Chuck Stevens
05-24-05 08:55 PM


Re: Passing an invalid date to INTEGER-OF-DATE
Walter,
I haven't tried it recently, but I think that IBM mainframes give a run-time
error and terminate.  I know that when you do "similar" things with their
callable services, you get something like the message at:

http://publibz.boulder.ibm.com/cgi-.../ceea9150/1.107

P.S.  Usual "reminder" the Intrinsic Function module was OPTIONAL in the '89
(not '85) ANSI/ISO Standard (even at the high level) - but was REQUIRED by t
he
FIPS High-Level specification.

There was NO requirement in any of these as to what happened with invalid
arguments.

--
Bill Klein
wmklein <at> ix.netcom.com
"Walter Murray" <wmurray@midtown.net> wrote in message
news:4292ab55$1_2@spool9-west.superfeed.net...
> What happens in COBOL if you reference the INTEGER-OF-DATE function and
> specify an invalid date for the argument?
>
> The 1985 COBOL standard says that anything can happen ("the result of such
 a
> reference is undefined").
>
> I would be interested to know the results for various compilers.  The
> question came up during a migration.
>
> Thanks.
>
> Walter
>
>
>
> ----== Posted via mcse.ms - Unlimited-Uncensored-Secure Usenet
> News==----
> http://www.mcse.ms The #1 Newsgroup Service in the World! 120,000+
> Newsgroups
> ----= East and West-Coast Server Farms - Total Privacy via Encryption =----[/color
]



Report this thread to moderator Post Follow-up to this message
Old Post
William M. Klein
05-25-05 01:55 AM


Re: Passing an invalid date to INTEGER-OF-DATE
I just found the correct run-time message.  See:

http://publibz.boulder.ibm.com/cgi-...S/ceea9150/7.87
and
http://publibz.boulder.ibm.com/cgi-...S/ceea9150/7.88


In "IBM-ese" there are a S-level messages and results in the programming
"ABENDing".

--
Bill Klein
wmklein <at> ix.netcom.com
"William M. Klein" <wmklein@nospam.netcom.com> wrote in message
news:omKke.493207$QY2.208777@fe01.news.easynews.com...
> Walter,
>  I haven't tried it recently, but I think that IBM mainframes give a run-t
ime
> error and terminate.  I know that when you do "similar" things with their
> callable services, you get something like the message at:
>
> http://publibz.boulder.ibm.com/cgi-.../ceea9150/1.107
>
> P.S.  Usual "reminder" the Intrinsic Function module was OPTIONAL in the '
89
> (not '85) ANSI/ISO Standard (even at the high level) - but was REQUIRED by
 the
> FIPS High-Level specification.
>
> There was NO requirement in any of these as to what happened with invalid
> arguments.
>
> --
> Bill Klein
> wmklein <at> ix.netcom.com
> "Walter Murray" <wmurray@midtown.net> wrote in message
> news:4292ab55$1_2@spool9-west.superfeed.net... 
>
>



Report this thread to moderator Post Follow-up to this message
Old Post
William M. Klein
05-25-05 01:55 AM


Re: Passing an invalid date to INTEGER-OF-DATE
Note that Unisys MCP COBOL85 gives a zero response to an INTEGER-OF-DATE
call in which any part of the argument is incorrect -- for example, 20050532
and 20051324 will both return zero.

It's not clear from these references whether IBM COBOL rejects invalid dates
larger than 16010101 and smaller than 99991231 as arguments to this
function.

In the MCP COBOL85 implementation, comparison of FUNCTION INTEGER-OF-DATE
(FUNCTION DATE-OF-INTEGER (A-DATE)) against A-DATE will fail if A-DATE is
nonzero and not a valid date.

-Chuck Stevens

"William M. Klein" <wmklein@nospam.netcom.com> wrote in message
news:4pKke.165992$gX5.85376@fe04.news.easynews.com...
> I just found the correct run-time message.  See:
>
>   http://publibz.boulder.ibm.com/cgi-...S/ceea9150/7.87
> and
>  http://publibz.boulder.ibm.com/cgi-...S/ceea9150/7.88
>
>
> In "IBM-ese" there are a S-level messages and results in the programming
> "ABENDing".
>
> --
> Bill Klein
>  wmklein <at> ix.netcom.com
> "William M. Klein" <wmklein@nospam.netcom.com> wrote in message
> news:omKke.493207$QY2.208777@fe01.news.easynews.com... 
run-time 
their 
http://publibz.boulder.ibm.com/cgi-.../ceea9150/1.107 
'89 
by the 
invalid 
such a 
120,000+ 
=---- 
>
>



Report this thread to moderator Post Follow-up to this message
Old Post
Chuck Stevens
05-25-05 01:55 AM


Re: Passing an invalid date to INTEGER-OF-DATE
Sorry, I got that backward.  Last paragraph, for

<<In the MCP COBOL85 implementation, comparison of FUNCTION INTEGER-OF-DATE
(FUNCTION DATE-OF-INTEGER (A-DATE)) against A-DATE will fail if A-DATE is
nonzero and not a valid date.>>

please read

> In the MCP COBOL85 implementation, comparison of FUNCTION DATE-OF-INTEGER
(FUNCTION INTEGER-OF-DATE (A-DATE)) against A-DATE will fail if A-DATE is
nonzero and not a valid date.

-Chuck Stevens



Report this thread to moderator Post Follow-up to this message
Old Post
Chuck Stevens
05-25-05 01:55 AM


Re: Passing an invalid date to INTEGER-OF-DATE
On 24-May-2005, "Chuck Stevens" <charles.stevens@unisys.com> wrote:

> Note that Unisys MCP COBOL85 gives a zero response to an INTEGER-OF-DATE
> call in which any part of the argument is incorrect -- for example, 200505
32
> and 20051324 will both return zero.

IMHO, the biggest weakness in the CoBOL language is that it was not designed
 for
easy standard error handling.    This particular solution is easy, but doesn
't
work for all function calls.      ON ERROR would have been a better design -
 as
a standard.

Report this thread to moderator Post Follow-up to this message
Old Post
Howard Brazee
05-25-05 01:55 AM


Re: Passing an invalid date to INTEGER-OF-DATE
I'm not convinced ON ERROR is necessarily the best approach here, or for
that matter in general, particularly given the ability to "nest" function
calls.

The '02 standard includes exception handling (for this and in general) in a
way that, in my opinion, doesn't invalidate existing programs and allows
their enhancement to catch such problems.  Lobby your vendors!

-Chuck Stevens

"Howard Brazee" <howard@brazee.net> wrote in message
news:d6vutt$3fp$1@peabody.colorado.edu...
>
> On 24-May-2005, "Chuck Stevens" <charles.stevens@unisys.com> wrote:
> 
20050532 
>
> IMHO, the biggest weakness in the CoBOL language is that it was not
designed for
> easy standard error handling.    This particular solution is easy, but
doesn't
> work for all function calls.      ON ERROR would have been a better
design - as
> a standard.



Report this thread to moderator Post Follow-up to this message
Old Post
Chuck Stevens
05-25-05 01:55 AM


Re: Passing an invalid date to INTEGER-OF-DATE
On 24-May-2005, "Chuck Stevens" <charles.stevens@unisys.com> wrote:

> I'm not convinced ON ERROR is necessarily the best approach here, or for
> that matter in general, particularly given the ability to "nest" function
> calls.
>
> The '02 standard includes exception handling (for this and in general) in 
a
> way that, in my opinion, doesn't invalidate existing programs and allows
> their enhancement to catch such problems.  Lobby your vendors!

I didn't say "best", I said "better".   It would have worked with the origin
al
design, but would have had to have been enhanced over time.

Report this thread to moderator Post Follow-up to this message
Old Post
Howard Brazee
05-25-05 01:55 AM


Re: Passing an invalid date to INTEGER-OF-DATE
Walter Murray wrote:
> What happens in COBOL if you reference the INTEGER-OF-DATE function
> and
> specify an invalid date for the argument?
>
> The 1985 COBOL standard says that anything can happen ("the result of
> such a reference is undefined").
>
> I would be interested to know the results for various compilers.  The
> question came up during a migration.
>
> Thanks.
>
> Walter

You should test it in your world. You may have to:

If MYDATE-YYYY NUMERIC
If MYDATE-YYYY > 1800 And < 2100
..
COMPUTE MYDATE-INT = FUNCTION INTEGER-OF-DATE(MYDATE)

Our compiler (Fujitsu) goes nuts when an invalid field is passed to FUNCTION
NUMVAL. For those instances where we can't guarantee the integrity of the
field, we're oblidged to test each character before we hand the field to
NUMVAL.




Report this thread to moderator Post Follow-up to this message
Old Post
HeyBub
05-25-05 08:55 AM


Sponsored Links




Last Thread Next Thread Next
Pages (2): [1] 2 »
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 04:54 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.