I posted the following two days ago and just realized that in the first sentence I said "cannot" when I meant "can."  Here it is again.  Sorry for the error.  I am deleting the earlier message.

You CAN 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 failed
Mel Rothman, CGIDEV2 Author
Mel Rothman, Inc.


smit_al wrote: Rich,

I think it would be nice to have the zhbgetvar procedure have the
ability to convert an html variable to numeric, if the user passes a
parm to do so. 

--- In [email protected], "Rich Diedrich" <[EMAIL PROTECTED]> wrote:
>
> I really appreciate the suggestions that I have received so far, both
> on this site and through email, and I would like to repeat that this
> is a good time to let me know what you would like enhanced.  I will
> evaluate all of the suggestions (and the discussions on the
> controversial ones), and use that information to help me shape the
> enhancements and future direction of CGIDEV2. 
>
> The suggestions do not have to be specific implementation changes, but
> can include more general requests, like the one for more assistance in
> handling persistence data.
>
> Rich
>



SPONSORED LINKS
How to format a computer hard drive Cobol programmer Iseries 400
How to format a computer


YAHOO! GROUPS LINKS




Reply via email to