× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: RE: Char to numeric conversion question
  • From: Ken Slaugh <ken.slaugh@xxxxxxxxxx>
  • Date: Thu, 22 Apr 1999 11:01:37 -0700

Here's a sniplet of code to convert alpha to number/date/boolean

      * BOOLEAN FIELDS                                      
     C                     MOVEL##ALPH    #A2     2         
B1   C           #A2       IFEQ '-1'                        
     C                     MOVE 'Y'       ##YN    1         
X1   C                     ELSE                             
     C                     MOVE 'N'       ##YN              
E1   C                     ENDIF                            
      * NUMERIC                                             
     C                     Z-ADD0         ##NUMB 154        
     C           ' '       CHEKR##ALPH    #5END   50     19 
B1   C           *IN19     IFEQ *ON                         
     C                     Z-ADD1         #DIVS   40   1112 
B2   C                     DO   #5END     #5      50        
     C           1         SUBST##ALPH:#5 #A1     1         
     C  N11      #A1       COMP '.'                      11 
     C  N12      #A1       COMP '-'                      12 
B3   C           #A1       IFGE '0'                         
     C           #A1       ANDLE'9'                                
     C                     MOVE #A1       #1      10               
B4   C           *IN11     IFEQ *OFF                       WHOLE # 
     C                     MULT 10        ##NUMB                   
     C                     ADD  #1        ##NUMB                   
X4   C                     ELSE                                    
     C                     MULT 10        #DIVS            DECIMALS
B5   C           #DIVS     IFGT *ZERO                              
     C           #1        DIV  #DIVS     #44     44               
     C                     ADD  #44       ##NUMB                   
E5   C                     ENDIF                                   
E4   C                     ENDIF                                   
E3   C                     ENDIF                                   
E2   C                     ENDDO                                   
     C   12                Z-SUB##NUMB    ##NUMB                   
E1   C                     ENDIF                                   
      * DATES (MM/DD/YY)     
     C                     Z-ADD##NUMB    ##MDY    
     C           ##MM      IFNE *ZERO              
B1   C           ##YY      IFLT 50                 
     C                     Z-ADD20        ##CC     
X1   C                     ELSE                    
     C                     Z-ADD19        ##CC     
E1   C                     ENDIF                   
     C                     ELSE                    
     C                     Z-ADD0         ##CC     
E1   C                     ENDIF                   


Ken Slaugh
Senior Programmer/System Analyst
AS/400 Professional Network Administrator/MSE
Specialist - Client Access/400
Chouinard & Myhre, Inc.

> -----Original Message-----
> From: Colin Williams [SMTP:Williamsc@technocrats.co.uk]
> Sent: Tuesday, April 20, 1999 12:18 AM
> To:   'RPG400-L@midrange.com'
> Subject:      RE: Char to numeric conversion question
> 
> Cant you MOVE the character field to a 9,2 zoned field, then Z-ADD the
> zoned field into a 9,2 packed field?
> 
> -----Original Message-----
> From: Paul Jackson [mailto:paulgjackson@yahoo.com]
> Sent: Monday, April 19, 1999 9:15 PM
> To: RPG400-L@midrange.com
> Subject: Char to numeric conversion question
> 
> 
> Hello All,
> 
> Ok here's my problem. I am converting a spool file
> into a data base work file.  I am reading the spooled
> file records and trying to convert edited numeric
> values into packed fields for storage.
> 
> For example I have a value from the spool file that
> comes in as character 'bbbbb25.03' and I want to put
> this into a 9,2 packed field.
> 
> I looked for RPGIV built in functions but could find
> none that seemed to do the job.  Any suggestions on
> how to do this in a relatively simple way?
> 
> Thanks in advance
> -Paul
> 
> ===
> Paul G.Jackson
> IBM Certified Specialist - AS/400 RPG Programmer
> Home: (425) 401-0224   paulgjackson@yahoo.com 
> Work: (425) 313-8594   pjackson@costco.com    
> 
> Boycott Proctor & Gamble products-see http://www.pginfo.net
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
> 
> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
> *
> *
> * This is the RPG/400 Discussion Mailing List!  To submit a new
> *
> * message, send your mail to "RPG400-L@midrange.com".  To unsubscribe
> *
> * from this list send email to MAJORDOMO@midrange.com and specify
> *
> * 'unsubscribe RPG400-L' in the body of your message.  Questions
> should
> *
> * be directed to the list owner / operator: david@midrange.com
> *
> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
> *
> *
> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
> * *
> * This is the RPG/400 Discussion Mailing List!  To submit a new
> *
> * message, send your mail to "RPG400-L@midrange.com".  To unsubscribe
> *
> * from this list send email to MAJORDOMO@midrange.com and specify
> *
> * 'unsubscribe RPG400-L' in the body of your message.  Questions
> should *
> * be directed to the list owner / operator: david@midrange.com
> *
> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
> * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* This is the RPG/400 Discussion Mailing List!  To submit a new         *
* message, send your mail to "RPG400-L@midrange.com".  To unsubscribe   *
* from this list send email to MAJORDOMO@midrange.com and specify       *
* 'unsubscribe RPG400-L' in the body of your message.  Questions should *
* be directed to the list owner / operator: david@midrange.com          *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 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.