Artikelergänzung: Hilfe, ein API”, Teil 2

Nov 12th, 2008 | By Redaktion | Category: Aufgabenstellungen, Load`n`go, Solutions & Provider

Artikelergänzung
Hilfe, ein API", Teil 2

Als Ergänzung zum Artikel "Hilfe, ein API", Teil 2 der Märzausgabe 2004 der NEWSolutions veröffentlichen wir hier die beschriebenen Programmtechniken (Abbildung 5a und 5b):

Utility der NEWSolutions
Load´n´go

Abbildung 5a: Arbeiten mit Offsets

D Object          DS         32048    Qualified
D                                     Inz
D  Name                         10
D  Library                      10
D  OffsetToAttr                 10I 0
D  NbrAttr                      10I 0
D  OffsetToUsr                  10I 0
D  NbrUsr                       10I 0

D Count           S             10I 0
D Pos             S             10I 0
D Info            S             10
D Info2           S             10    Based( Info2Ptr )
D Info2Ptr        S               *

/Free

  //  =================================================================  [A]
  //  = Display information using substringing                        =
  //  =================================================================

  //  -----------------------------------------------------------------
  //  - Display each attribute                                        -
  //  -----------------------------------------------------------------

      For Count = 1 to Object.NbrAttr ;
        Pos = Object.OffsetToAttr + 1 + ( ( Count - 1 ) * 10 ) ;
        Info = %Subst( Object : Pos : 10 ) ;
        Dsply Info ;
      EndFor ;

  //  -----------------------------------------------------------------
  //  - Display each authorized user                                  -
  //  -----------------------------------------------------------------

     For Count = 1 to Object.NbrUsr ;
       Pos = Object.OffsetToUsr + 1 + ( ( Count - 1 ) * 10 )
       Info = %Subst( Object : Pos : 10 ) ;
       Dsply Info ;
     EndFor ;

  //  =================================================================  [B]
  //  = Display information using based variables                     =
  //  =================================================================

  //  -----------------------------------------------------------------
  //  - Display each attribute                                        -
  //  -----------------------------------------------------------------

      For Count = 1 to Object.NbrAttr ;
        Pos = Object.OffsetToAttr + ( ( Count - 1 ) * 10 ) ;
        Info2Ptr = %Addr( Object ) + Pos ;
        Dsply Info2 ;
      EndFor ;

  //  -----------------------------------------------------------------
  //  - Display each authorized user                                  -
  //  -----------------------------------------------------------------

      For Count = 1 to Object.NbrUsr ;
        Pos = Object.OffsetToUsr + ( ( Count - 1 ) * 10 ) ;
        Info2Ptr = %Addr( Object ) + Pos ;
        Dsply Info2 ;
      EndFor ;

 /End-Free

 

Abbildung 5b: Arbeiten mit Displacements
 

D Object          DS         32048    Qualified
D                                     Inz
D  Name                         10
D  Library                      10
D  DispToAttr                   10I 0
D  NbrAttr                      10I 0
D  DispToUsr                    10I 0
D  NbrUsr                       10I 0

D Count           S             10I 0
D Pos             S             10I 0
D Info            S             10    Based( InfoPtr )
D InfoPtr         S               *

/Free

  //  ===========================================================
  //  = Display information                                     =
  //  ===========================================================

  //  -----------------------------------------------------------
  //  - Display each attribute
  //  -----------------------------------------------------------

      For Count = 1 to Object.NbrAttr ;
        Pos = Object.DispToAttr + ( ( Count - 1 ) * 10 ) ;
        InfoPtr = %Addr( Object.DispToAttr ) + Pos ;
        Dsply Info ;
      EndFor ;

  //  -----------------------------------------------------------
  //  - Display each authorized user
  //  -----------------------------------------------------------

      For Count = 1 to Object.NbrUsr ;
        Pos = Object.DispToUsr + ( ( Count - 1 ) * 10 ) ;
        InfoPtr = %Addr( Object.DispToUsr ) + Pos ;
        Dsply Info ;
      EndFor ;

 /End-Free
Tags: , , , , , , ,

Leave Comment