|
You cannot combine zhbgetvar
& c2n2 today. In the example, below, I modified TEMPLATE5 to
process the custname field as a number by combining ZhbGetVar and C2n2
into one statement. I show only the added and modified code. Note that c2n2 ignores all characters except numerals, the current decimal point, and a leading or trailing minus sign. It returns a 15p 5 which can be assigned to smaller numeric variables, but it is your responsibility to make sure there won't be overflow to the left of the decimal point (detected by monitor) or to the right of the decimal point (not detected, extra least significant digits are truncated). For more details about c2n2, see its prototype in CGIDEV2/QRPGLESRC member PROTOTYPEB and its code in member XXXDATA. My recommendation is to continue to separate the two operations, inserting an edit using chkNbr in between them. The various TEMPLATE programs use this method. Anyway, here is the code: * For testing a number D theNumber s 5p 2 D theMessage s 40
theMessage = '';
monitor;
theNumber = c2n2(zhbgetvar('custname'));
on-error;
theMessage = %trimr(custname) + ' It failed';
endmon;
if theMessage = '';
theMessage = %trimr(custname) + ' Ok. Value: ' + %char(theNumber);
endif;
// Set up data for writing standard output.
updHTMLvar('custname':theMessage :InitHTMLVars);
Here are inputs and results (minus the template output HTML): blanks: Ok. Value: .00 abc abc Ok. Value: .00 1.23 1.23 Ok. Value: 1.23 -1.2-3- -1.2-3- Ok. Value: -1.23 1.234 1.234 Ok. Value: 1.23 123 123 Ok. Value: 123.00 123.456 123.456 Ok. Value: 123.45 1234 1234 It failedMel Rothman, CGIDEV2 Author Mel Rothman, Inc. smit_al wrote: Rich,
SPONSORED LINKS
YAHOO! GROUPS LINKS
|
- [Easy400Group] Enhancement requests Rich Diedrich
- [Easy400Group] Re: Enhancement requests smit_al
- RE: [Easy400Group] Re: Enhancement requests Jon Paris
- RE: [Easy400Group] Re: Enhancement requests Antoon van Os
- Re: [Easy400Group] Re: Enhancement requests Mel Rothman
- [Easy400Group] Re: Enhancement requests Mel Rothman
- Re: [Easy400Group] Enhancement requests mattlavinder
- Re: [Easy400Group] Enhancement requests Mel Rothman
