|
A method that I use is: * Check for a negitive sign 0221.29 C If %scan('-':%trim($20Alp)+' ')>0 0221.30 C Z-add -1 Alp_Sign 1 0 0221.31 C '-':' ' Xlate $20Alp $20Alp 0221.32 C Else 0221.33 C Z-add 1 Alp_sign 0221.34 C endif * Right justify and Pad with zeros 0221.36 C if 21-%scan(' ':%trim($20Alp)+' ')>0 0221.37 C Eval $20Alp =%subst('00000000000000000000':1: 0221.38 C 21-%scan(' ':%trim($20Alp)+' ')) + 0221.39 C %subst(%trim($20Alp)+' ':1: 0221.40 C %scan(' ':%trim($20Alp)+' ')) 0221.41 C endif *move into a numeric 10,0 field 0221.48 C Move $20Alp @10$0# *Multiply by sign field into a numeric 10,3 field 0221.56 C Eval @10$3# = @10$3# * Alp_sign I don't like taking a 20 digit field to a 10 digit field. You also stated that these were whole numbers, thus I did not allow for the decimal point. Eurrat P.S. Notice that I did not reopen the request made while back about a %Value function in honor of Mr. Boldt. -----Original Message----- From: Baltus, Kevin <KBaltus@automaticproducts.com> To: 'RPG400-L@midrange.com' <RPG400-L@midrange.com> Date: Friday, April 14, 2000 4:13 PM Subject: Convert Alpha to Numeric Hello. I may be asking a basic question but what is the best way to convert an alpha field into a numeric? In my situation I have a 20-Alpha where the values are whole numbers. I need to get that whole number into a 10.3 field. Any suggestions would be greatly appreciated! Thanks! -------------------------------------------------------- Kevin Baltus - Programmer/Analyst (651) 290-6179 kbaltus@automaticproducts.com Gross-Given Mfg/Automatic Products International http://www.automaticproducts.com Blatant Band Plug http://www.twitch.org +--- | This is the RPG/400 Mailing List! | To submit a new message, send your mail to RPG400-L@midrange.com. | To subscribe to this list send email to RPG400-L-SUB@midrange.com. | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +---
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.