× 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: right-adjusting a mixed field, selecting numbers only
  • From: boothm@xxxxxxxxxxxxxxxxx
  • Date: Tue, 26 Aug 97 18:26:16 -0400

OK, here's an old-fashioned way to get your string right-adjusted, and     
 numbers only:                                                               
(Set your font to fixed to read this!)                                     
 Definitions:                                                                
   FROM     A 15 character field that is our original data field.            
   TARGET  A 15 character field that is our new, right adjusted,            
              numbers only field.                                               
   ARI       An array; 15 elements each 1 character long, for input.          
   ARO      An array; 15 elements each 1 character long, for output.         
   I          A 2-digit field for an index of the ARI array.                   
   O         A 2-digit field for an index of the ARO array.                   
                                                                            
Narrative: We'll move our FROM field into the ARI array and then starting  
 at the end (element 15) we will go backwards.  As we go backwards we will   
check each element of ARI to see if it is a number.  If it is a number we  
 will move it to the "O" element of ARO and decrement the index "O" for ARO     
by 1.  When done, we will then move our ARO array to our finish field,     
 TARGET.                                                                     
                                                                            
    * -------------------------------------------------------               
   E                              ARI   15  1                               
   E                              ARO   15  1                               
    * -------------------------------------------------------               
    * Set our array indexes (note that we are setting the arrary index      
    * at 15 and decrementing it  -  this gets us right adjusted):           
   C                 Z-ADD15     I     20
   C                 Z-ADD15     O    20     
    * Move our "from" field into the array ARI:                             
   C                 MOVEAFROM   ARI                                        
    * Read through the array ARI, an element at a time:                     
   C                 DO   15                                                
    * If the array element is >=0, and <=9, choose it:                      
   C        ARI,I    IFGE '0'                                               
   C        ARI,I    ANLE '9'                                               
    * It is chosen, and moved to right side of the array ARO:               
   C                 MOVE ARI,I  ARO,O                                      
   C                 SUB  1      O                                          
   C                 ENDIF                                                  
   C                 SUB  1      I                                          
   C                 ENDDO                                                  
    * Once we are done, move the array ARO to our desired field:            
                     MOVEA ARO   TARGET                                     
    * ---------------------------------------------------------- 
    * This process will move a field like  "A1$2e45(*&6asd7"                
    *                                     to  "        1234567"                
    * ----------------------------------------------------------            


-- 
-----------------------------------------------------------
boothm@earth.goddard.edu
-----------------------------------------------------------

+---
| This is the Midrange System Mailing List!
| To submit a new message, send your mail to "MIDRANGE-L@midrange.com".
| To unsubscribe from this list send email to MAJORDOMO@midrange.com
|    and specify 'unsubscribe MIDRANGE-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.