× 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: Data Structures with Structures
  • From: "Simon Coulter" <shc@xxxxxxxxxxxxxxxxx>
  • Date: Fri, 22 Jun 01 15:47:47 +1000


Hello Erick,

You can overlay the array with the required subfields.  Doing so allows you 
to reference the subfields with an index because they are also arrays in 
their own right.  (This is a neat trick when you need to sort an array by 
different subfields.)

You should also use Integer data types for the command analyzer count 
field. (You probably don't need acmds at all.)

You should also use length notation rather than positional notation for 
the DS subfields.

Implementing the above gives you a structure like:

d @@faxcmds       ds                                       
d  acmds                         2                         
d    bcmds                       5I 0 overlay(acmds)       
d  faxcmdds                     18a   dim(40)              
d    faxqual                    10a   overlay(faxcmdds:1)  
d    faxqualbc                   4s 0 overlay(faxcmdds:11) 
d    faxqualec                   4s 0 overlay(faxcmdds:15) 

On VRM440 and above you can use *NEXT for the OVERLAY keywords to avoid 
manually calculating them.  For example:

d    faxqual                    10a   overlay(faxcmdds)  
d    faxqualbc                   4s 0 overlay(faxcmdds:*NEXT) 
d    faxqualec                   4s 0 overlay(faxcmdds:*NEXT) 

If you've defined the command parameter properly then you'll find that 
there is an additional count field for each element indicating the number 
of subfields and an array of integers after the initial element count with 
the offsets to the elements themselves.  

Please tell me you haven't done something ugly like define an 18 character 
parameter and expect the user to pad the elements manually?  Please tell me 
you haven't used character fields for numeric values?  You should have a 
command definition something like:

             PARM       KWD(FAXCMD) TYPE(E1) MAX(40) +      
                          PROMPT('Facsimile commands')      
                                                            
 E1:         ELEM       TYPE(*CHAR) LEN(10) PROMPT('Command') 
             ELEM       TYPE(*INT2) RANGE(1 9999) PROMPT('Begin')      
             ELEM       TYPE(*INT2) RANGE(1 9999) PROMPT('End')      

Of course, defining the parameter like this means you need to use a based 
structure to navigate the element lists but that is easy enough.

Ensure enough room for 40 elements (2-byte count, 10-byte char, 2-byte 
begin, 2-byte end) plus 40 offset values, plus 2-byte element count.
d @@faxcmds       ds                                       
d  cmdCnt                        5I 0 
d  cmdOffset                     5I 0 dim(40)
d  faxcmdds                     16a   dim(40)              

d faxCmd          ds                  based(@faxCmd)
d    faxElem                     5I 0 overlay(faxCmd:1
d    faxqual                    10a   overlay(faxCmd:3)  
d    faxqualbc                   5I 0 overlay(faxCmd:13) 
d    faxqualec                   5I 0 overlay(faxCmd:15) 

and just move the based structure by adding the offsets in cmdOffset to the 
@faxCmd pointer inside a loop controlled by cmdCnt.  See Chapter 9 of the 
CL Programmer's Reference (or wherever IBM have hidden this stuff in the 
InfoCentre) for details on processing element lists properly.

Regards,
Simon Coulter.


 FlyByNight Software         AS/400 Technical Specialists       
 Eclipse the competition - run your business on an IBM AS/400.  
                                                                
 Phone: +61 3 9419 0175   Mobile: +61 0411 091 400        /"\   
 Fax:   +61 3 9419 0175   mailto: shc@flybynight.com.au   \ /   
                                                           X    
               ASCII Ribbon campaign against HTML E-Mail  / \   

+---
| 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 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.