|
Depends on how much you know about the integrity of the alpha field. If you are 100% sure that it contains only numeric characters or blanks and the blanks don't occur in the middle of the numeric characters, and you don't have to deal with signs, decimal points, or separator characters , you ought to be able to do it with a data structure. If you have to consider any of the conditions mentioned above, you'll have to write code to handle them and parse the alpha field. If you are sure that none of the character fields contain a whole number of more than 7 digits (largest you can get in a 10,3), you might look into using the C atol() function which can handle signed numbers up to 2^31 - 1. You have to use the binding directory QC2LE on the binding step. This won't give you the kind of error handling you can put into custom code. Here's a sample program that has a prototype for the function that you should be able to compile and run in debug to see what happens: 0001.00 D atol PR 10I 0 ExtProc('atol') 0002.00 D charnump * Value Options(*String) 0003.00 D charnum s 7 inz('-12345 ') 0004.00 D charnu2 s 7 inz('asdfx- ') 0005.00 D charnu3 s 7 inz('123 45 ') 0006.00 D longint s 10i 0 0007.00 D sixzone s 6s 0 0008.00 D 0009.00 C eval longint = atol(charnum) 0010.00 C eval sixzone = atol(charnum) 0011.00 C eval longint = atol(charnu2) 0012.00 C eval longint = atol(charnu3) 0013.00 C eval *inlr = *on -----Original Message----- From: Baltus, Kevin [mailto:KBaltus@automaticproducts.com] Sent: Friday, April 14, 2000 2:01 PM To: 'RPG400-L@midrange.com' 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-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.