|
Dang Scott, you must be psychotic... I mean... Psychic! That's just what I
used! LOL
On 4/19/06, Scott Klement <rpg400-l@xxxxxxxxxxxxxxxx> wrote:
>
>
> > That would have been smart of me to include!
> > V5R1
> >
> > Will either your R2 or R3 option work? (I'll be trying while I wait for
> a
> > response ~ Thanks...
>
> The %int() BIF in V5R1 doesn't know how to convert character to numeric,
> it only knows how to control the intermediate representation of numeric
> expressions.
>
> They added the ability to convert to numeric in V5R2.
>
> They added the ability for %DEC() to convert dates to numeric in V5R3.
>
> So, in V5R1 you can use %CHAR() to format the date, but you can't use %INT
> to convert it to numeric. A quick workaround is to use the ILE C runtime
> library for the char -> numeric conversion, an example follows:
>
> H DFTACTGRP(*NO) BNDDIR('QC2LE')
>
> D atoi pr 10I 0 extproc('atoi')
> D char * value options(*string)
>
> D result s 8 0
> /free
>
> result = atoi( %char( %date() : *ISO0 ) );
> dsply result;
>
> *inlr = *on;
> /end-free
>
> Personally, I'd wrap that up in a subprocedure and stick it in a global
> "utilities" service program so you never have to worry about it again.
>
> If you want to do it in "pure RPG" in V5R1, you'll have to use a data
> structure for the character to numeric conversion. For example:
>
> D chardate ds
> D result 8S 0
>
> /free
>
> chardate = %char( %date() : *ISO0 );
> dsply result;
>
> *inlr = *on;
> /end-free
>
> Good luck
>
> --
> This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
> To post a message email: RPG400-L@xxxxxxxxxxxx
> To subscribe, unsubscribe, or change list options,
> visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
> or email: RPG400-L-request@xxxxxxxxxxxx
> Before posting, please take a moment to review the archives
> at http://archive.midrange.com/rpg400-l.
>
>
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.