ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

clear data structure array

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • clear data structure array

    Hi guys,

    i have a problem with the data structure.
    is there anyway to clear the data structure array without
    looping the program with ocur???
    just one step just usual array.


    Code:
    I  DSDT        DS                         99              
    I                                            1  22 #DT1  
    I                                            1  110#DSACC
    I                                           12  13 #DSKDW
    I                                           14  220#DSNOW
    
    it just a simple coding like this :
    
    C   2         OCUR    DSDT           
    C              MOVEL  'TEST'    DSDT 
    C   1         OCUR    DSDT           
    C              CLEAR   DSDT           
    C   2         OCUR    DSDT           
    
    when i clear the DSDT, it only clear the data structure in occurence 1,
    is there anyway to clear all the DS without looping like this :
    
    C           Z-ADD1  $X      4 0
    C     $X  DOWLE  99
    C     $X  OCUR     DSDT
    C           CLEAR    DSDT
    C           ADD       1       $X
    C           ENDDO
    ???? any simple way like clear array? or function that i don't know maybe?

    Thx u

  • #2
    Re: clear data structure array

    clear DTST
    Jim Waymire

    Comment


    • #3
      Re: clear data structure array

      Well the first point to note is that you _don't_ have a DS array in your code - you have a multiple occurence DS (MODS) which is not the same thing. When you use a MODS - as you have noticed - you can only access (and therefore clear) one element at a time _unless_ you specify *All as Factor2 - in this case all elements are cleared.

      MODS are effectively deprecated with the advent of DS arrays in V5R2. Simply define DIM(...) on the DS definition line to define one. With these a CLEAR will always work on all elements.

      Comment


      • #4
        Re: clear data structure array

        so cannot clear all the Data Structure at once?
        if can, would u give me the example...
        right now i just using the RPG III, i'd like to use the rpg iv, but
        cannot do that, because of the project use the rpg iii.

        Thanks

        Comment


        • #5
          Re: clear data structure array

          the code u need to use is

          C CLEAR *ALL DSDT
          Thanks,
          Giri

          Comment


          • #6
            Re: clear data structure array

            oohh i think i get it, it seems the syntax only works in RPG IV. But now
            I am working on RPG III.
            BTW Thx guys

            Comment


            • #7
              Re: clear data structure array

              Sob!

              Why oh why is anyone still using RPG III !!

              The bl**dy thing has been obsolete for over 12 years! Isn't IBM saying that the S/36 and S/38 compilers are becoming a PRPQ after V5R4 enough writing on the wall to warn people to stop wasting their money!!!

              Snarl snarl snarl (can't see an icon for that!)


              Jon P

              Comment


              • #8
                Re: clear data structure array

                Count your blessings where they lie... at least it wasn't RPGII, using IDDU and OCL!

                Comment


                • #9
                  Re: clear data structure array

                  did someone say snarl?
                  Attached Files
                  All my answers were extracted from the "Big Dummy's Guide to the As400"
                  and I take no responsibility for any of them.

                  www.code400.com

                  Comment


                  • #10
                    Re: clear data structure array

                    Ewwww..... How bout RPGIII with member types of RPT? You never knew what copy book was for what part of the source.

                    Grandpa, can you make the dinosaur run across the screen again???

                    Ha ha ha ha ha ha ha!
                    Last edited by kpmac; February 22, 2006, 01:11 PM.
                    Predictions are usually difficult, especially about the future. ~Yogi Berra

                    Vertical Software Systems
                    VSS.biz

                    Comment


                    • #11
                      Re: clear data structure array

                      And ... don't forget .. that was also on the old ONE LINE SEU Editor!

                      Top 'o the line guys ... couldn't beat it with a drum stick!

                      Comment


                      • #12
                        Re: clear data structure array

                        okay tuff guys here it is with a straight CVTRPGSRC show me whatcha got

                        Code:
                             d DSDT            DS                  OCCURS(99)
                             d  CLK                    1    100
                             d  #DT1                   1     22
                             d  #DSACC                 1     11  0
                             d  #DSKDW                12     13
                             d  #DSNOW                14     22  0
                              *
                             c     *LIKE         DEFINE    MODE          SFLLOC
                              *
                             c     1             OCCUR     DSDT
                             c                   MOVEL     'TEST'        DSDT
                             c     2             OCCUR     DSDT
                             c                   CLEAR                   DSDT
                             c     3             OCCUR     DSDT
                             c                   CLEAR                   DSDT
                              *
                             C                   MOVE      *ON           *INLR
                        All my answers were extracted from the "Big Dummy's Guide to the As400"
                        and I take no responsibility for any of them.

                        www.code400.com

                        Comment


                        • #13
                          Re: clear data structure array

                          Code:
                           *-------------------------------------------------------------------*        
                           *                          Data Structs                             *        
                           *-------------------------------------------------------------------*        
                           *                                                                            
                           *                                                                            
                          D dsDT            DS                  OCCURS(99) Inz                          
                          D  CLK                         100A                                           
                          D  #DT                          22A   OverLay(CLK:1)                          
                          D  #DSACC                       11  0 OverLay(CLK:1)                          
                          D  #DSKDW                        2A   OverLay(CLK:12)                         
                          D  #DSNOW                        9  0 OverLay(CLK:14)                         
                           *                                                                            
                           *-------------------------------------------------------------------*        
                           *                           Constants                               *        
                           *-------------------------------------------------------------------*        
                           *                                                                            
                           *-------------------------------------------------------------------*        
                           *                          Stand Alone                              *        
                           *-------------------------------------------------------------------*        
                           *                                                                       
                          D idx             S              5I 0                                    
                           *=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=*   
                           *                             Main                                  *   
                           *=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=*   
                           *                                                                       
                           /free                                                                   
                                                                                                   
                                                                                                   
                              For idx = 1 to %Elem(dsDT);                                          
                                %Occur(dsDT) = idx;                                          
                                dsDT = 'Test';                                               
                              EndFor;                                                        
                                                                                             
                              Reset dsDT;                                                    
                                                                                             
                              Clear *All dsDT;                                               
                                                                                             
                              For idx = 1 to %Elem(dsDT);                                    
                                %Occur(dsDT) = idx;                                          
                                dsDT = *Blanks;                                              
                              EndFor;                                                        
                                                                                             
                              *InLr = *On;                                                   
                                                                                             
                           /end-free
                          Note: Clear *All and Reset will the numeric fields in the MOD to *Zeros and the For loop will set the values to *Blanks.
                          Predictions are usually difficult, especially about the future. ~Yogi Berra

                          Vertical Software Systems
                          VSS.biz

                          Comment


                          • #14
                            Re: clear data structure array

                            Nice - you dont get paid by the dash....do you?
                            All my answers were extracted from the "Big Dummy's Guide to the As400"
                            and I take no responsibility for any of them.

                            www.code400.com

                            Comment


                            • #15
                              Re: clear data structure array

                              Ha ha ha ha ha ha!!!! No, I have a slight problem called OCD.


                              Hey, everybody needs standards. I find that its easier to page around the code this way. I keep everything pretty much the same and its easy to get to my structs, Stand alones, Constants. . .
                              Last edited by kpmac; February 22, 2006, 01:55 PM.
                              Predictions are usually difficult, especially about the future. ~Yogi Berra

                              Vertical Software Systems
                              VSS.biz

                              Comment

                              Working...
                              X