Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

Application example

&pagelevel(5)&pagelevel

The example of a possible application which follows in full shows how the interaction of S procedures, S variable streams and FHS can be used to create a graphical library manager.

The individual S procedures which carry out this task are stored as J-type elements in the (user) library LIBRARY-MANAGER.PL, under the names RUN, SCREEN01 and
SCREEN02. RUN is the controlling S procedure, which is called by a CALL-PROCEDURE. On the other hand, SCREEN01 and SCREEN02 are dependent on RUN and are responsible for the two possible standard screen displays.

A listing of these three S procedures appears below. Following this, a few applications are indicated to demonstrate how this FHS-supported library manager can be used.

Procedure: RUN

/SET-PROCEDURE-OPTIONS CALLER=CALL
/
/"----------------------------------------------------------"
/"First get library name from which this procedure is called"
/"----------------------------------------------------------"
/
/DECLARE-VARIABLE SYSOUT(TYPE=*STRUCTURE),MULTIPLE-ELEMENTS=*LIST
/EXECUTE-CMD (SHOW-SYSTEM-FILE-ASSIGNMENT SYSTEM-FILE=*SYSCMD),-
            /STRUCTURE-OUTPUT=SYSOUT,TEXT-OUTPUT=*NONE 
/LIBRARY-NAME = SYSOUT#1.SYSCMD.LIB
/
/"----------------------------------------------------------"
/"Get FHS library names via IMON-GPN                        "
/"----------------------------------------------------------"
/
/FHSLNK = '$TSOS.SYSFHS.FHS.082.FHS-DM.D'
/FHSLNK = INSTALLATION-PATH(LOGICAL-ID        = 'SYSFHS.FHS-DM.D' , -
                           /INSTALLATION-UNIT = 'FHS' , -
                           /VERSION           = *STD , -
                           /DEFAULT-PATH-NAME = FHSLNK) 
/
/FHSPRC = '$TSOS.SYSPRC.FHS.082'
/FHSPRC = INSTALLATION-PATH(LOGICAL-ID        = 'SYSPRC' , -
                           /INSTALLATION-UNIT = 'FHS' , -
                           /VERSION           = *STD , -
                           /DEFAULT-PATH-NAME = FHSPRC) 
/
/"----------------------------------------------------------"
/"Get SDF-P-BASYS library name via IMON-GPN                 "
/"----------------------------------------------------------"
/
/SDPPRC = '$TSOS.SYSPRC.SDF-P-BASYS.022'
/SDPPRC = INSTALLATION-PATH(LOGICAL-ID        = 'SYSPRC' , -
                           /INSTALLATION-UNIT = 'SDF-P-BASYS' , -
                           /VERSION           = *STD , -
                           /DEFAULT-PATH-NAME = SDPPRC) 
/
/"--------------------------------------------------------------"
/"Initialize FHS control variables                              "
/"--------------------------------------------------------------"
/WRITE-TEXT 'LIBRARY MANAGER V1.0 - LOADING'
/SHOW-VAR *ALL
/INCLUDE-PROCEDURE *LIBRARY-ELEMENT(LIBRARY = &(SDPPRC) -
/                                  ,ELEMENT = FHDR) -
/                 ,PROCEDURE-PARAMETERS = (PREFIX = 'SYSFHS-')
/SHOW-VAR *ALL
/INCLUDE-PROCEDURE *LIBRARY-ELEMENT(LIBRARY = &(FHSPRC) -
/                                  ,ELEMENT = SYSFHS-CONTROL)
/DECLARE-VARIABLE  SYSPINFO (TYPE = *STRUCTURE(SYSFHS-LAYOUT))
/DECLARE-VARIABLE  SYSPINFO-SAVE (TYPE = *STRUCTURE(SYSFHS-LAYOUT))
/INCLUDE-PROCEDURE *LIBRARY-ELEMENT(LIBRARY = &(FHSPRC) -
/                                  ,ELEMENT = SYSFHS-CONTROL) -
/                 ,PROCEDURE-PARAMETERS = (INCLUDE-FORM='INITIALIZE' -
/                                         ,VARIABLE-NAME='SYSPINFO')
/
/"--------------------------------------------------------------"
/"Assign the stream to FHS                                      "
/"--------------------------------------------------------------"
/ADD-FILE-LINK LINK-NAME=BLSLIB01,FILE-NAME=&(FHSLNK) 
/ASSIGN-STREAM STREAM-NAME = PRESENTATION -
/             ,TO          = *SERVER(FHS -
/             ,SERVER-INFO = 'FHS-LIB = &(LIBRARY-NAME)')
/
/"--------------------------------------------------------------"
/"Start LMS                                                     "
/"--------------------------------------------------------------"
/ASSIGN-SYSOUT TO=*DUMMY
/START-LMS
/HOLD-PROGRAM
/ASSIGN-SYSOUT TO=*PRIMARY
/
/"-----------------------------------------------------------------"
/"Set timeout to 0 when switching from line mode to full screen    "
/"-----------------------------------------------------------------"
/MODIFY-TERMINAL-OPTIONS OVERFLOW-CONTROL = *TIME(TIMEOUT = 0)
/
/"--------------------------------------------------------------"
/"Call main procedure (screen01)                                "
/"--------------------------------------------------------------"
/INCLUDE-PROCEDURE *LIBRARY-ELEMENT(LIBRARY = &(LIBRARY-NAME) -
/                                  ,ELEMENT = SCREEN01)
/
/"--------------------------------------------------------------"
/"Stop  LMS                                                     "
/"--------------------------------------------------------------"
/RESUME-PROGRAM
//END

Procedure: SCREEN01

/declare-variable screen01(type=*structure(*by-syscmd))
/begin-structure
/  declare-element name = filelist (type = *structure(*by-syscmd)) -
/                 ,multiple-elements = *list
/  begin-structure
/    declare-element choice
/    declare-element f-size
/    declare-element cat-id
/    declare-element user-id
/    declare-element short-f-name
/  end-structure
/  declare-element name = sdfplist-modindex (type = integer) -
/                 ,multiple-elements = *list
/  declare-element sdfplist-topindex(initial-value = 1)
/  declare-element sdfplist-botindex
/  declare-element sdfplist-numrow
/  declare-element file-menu
/  declare-element file-choice 
/end-structure
/
/declare-variable i(type = *integer)
/
/while (true)
/
/     "initialize modindex list for 50 elements "
/     " (fhs requirement)                       "
/     for i = *counter(1,50) 
/        screen01.sdfplist-modindex#&(i) = 0
/     end-for
/
/     "get library names"
/     exec-cmd cmd=(show-file-attributes -
/                     select=*by-attributes(type-of-files = *plam-library) -
/                    ,info=*name-and-space -
/                  ) -
/             ,structure-output=screen01.filelist -
/             ,text-output=*none -
/             ,returncode=*variable(subcode2=sub2 -
/                                  ,subcode1=sub1 -
/                                  ,maincode=main)
/
/     if (sub1 ne 0)
/        write-text 'Error &sub2 &sub1 &main returned by EXEC-CMD'
/        write-text 'LIBRARY MANAGER V1.0 abnormally terminated'
/        exit-procedure
/     end-if
/
/     syspinfo.resource = 'screen01'
/     syspinfo.service = '*display'
/     syspinfo.refresh = '*yes'
/     syspinfo.command = ''
/     screen01.sdfplist-numrow = size('screen01.filelist')
/     screen01.file-menu=0
/     screen01.file-choice=0
/     transmit-by-stream variable-name = screen01 -
/                       ,stream-name = presentation -
/                       ,control-var-name = syspinfo
/
/     if (   (syspinfo.std-header.returncode.maincode == 'IDH0004') -
/         or (syspinfo.std-header.returncode.maincode == 'IDH0008'))
/        write-text 'LIBRARY MANAGER V1.0 normally terminated'
/        exit-procedure
/     end-if
/
/     if (syspinfo.std-header.returncode.maincode ne 'IDH0000')
/        sub2 = syspinfo.std-header.returncode.subcode2
/        sub1 = syspinfo.std-header.returncode.subcode1
/        main = syspinfo.std-header.returncode.maincode
/        write-text 'Error &sub2 &sub1 &main returned by FHS server'
/        write-text 'LIBRARY MANAGER V1.0 abnormally terminated'
/        exit-procedure
/     end-if
/
/     if screen01.file-menu ne 0
/        if screen01.file-choice == 9
/           write-text 'LIBRARY MANAGER V1.0 normally terminated'
/           exit-procedure
/        else-if screen01.file-choice == 1
/         for i = *counter(1,size('screen01.sdfplist-modindex')), -
/              cond=(screen01.sdfplist-modindex#i ne 0)
/              screen01-curr-index = screen01.sdfplist-modindex#i
/              if screen01.filelist#screen01-curr-index.choice == '/'
/                 syspinfo-save = syspinfo
/                 include-procedure -
/                    name=*library-element(&library-name. -
/                                        ,screen02) -
/                   ,procedure-parameters=(&(screen01.filelist#screen01-currindex.short-f-name))
/                 if-cmd-error
/                    write-text 'LIBRARY MANAGER V1.0 abnormally terminated'
/                    exit-procedure
/                 else
/                    save-returncode
/                    if (maincode() = 'STOP0OK')
/                       write-text 'LIBRARY MANAGER V1.0 normally terminated'
/                       exit-procedure
/                    end-if
/                 end-if
/                 syspinfo = syspinfo-save
/              end-if
/           end-for
/        end-if
/     end-if
/
/     if (syspinfo.command ne '')
/        exec-cmd cmd=(&(syspinfo.command)) -
/                ,text-output=*none -
/                ,returncode=*variable(subcode2=sub2 -
/                                     ,subcode1=sub1 -
/                                     ,maincode=main)
/
/        if (sub1 ne 0)
/           write-text 'Error &sub2 &sub1 &main returned by command server'
/           write-text 'LIBRARY MANAGER V1.0 abnormally terminated'
/           exit-procedure
/        end-if
/     end-if
/end-while

Procedure: SCREEN02

/begin-parameter-declaration
/  declare-parameter library
/end-parameter-declaration
/
/declare-variable screen02(type=*structure(*by-syscmd))
/begin-structure
/  declare-element name = elemlist(type = *structure(*dynamic)) -
/                 ,multiple-element = *list
/  declare-element name = sdfplist-modindex(type = *integer) -
/                 ,multiple-element = *list
/  declare-element sdfplist-topindex(initial-value = 1)
/  declare-element sdfplist-botindex
/  declare-element sdfplist-numrow
/  declare-element file-menu
/  declare-element file-choice
/end-structure
/
/declare-variable sysout(type = *string), multiple-elements = *list
/declare-variable error-on-print( type = *boolean, initial-value = false )
/declare-variable i(type = *integer)
/
/resume-program
//open-library library = &library.,mode = *update
/hold-program
/
/while (true)
/
/   "initialize modindex list for 50 elements "
/   " (fhs requirement)                       "
/   for i = *counter(1,50)
/      screen02.sdfplist-modindex#&(i) = 0
/   end-for
/
/   assign-sysout to = *variable(sysout)
/   resume-program
//  show-element-attributes -
//       element = *library-element(library = *std -
//                                 ,element = *all ( version = *all ) -
//                                 ,type = *all) -
//      ,information = *maximum -
//      ,sort = *by-name -
//      ,structure-output = screen02.elemlist
/   hold-program
/   assign-sysout to = *primary
/
/   if ( stmt-spinoff() == 'YES' )
/      show-variable sysout, information = *parameters( name = *none )
/      maincode = 'LMS0ERR'
/      goto end
/   end-if
/
/   "Following loop is only necessary to rep a problem between"
/   "FHS and VAS. Correction in VAS V02.0A85, FHS V08.1A75"
/   for i = *counter(1,size('screen02.elemlist'))
/       screen02.elemlist#i.choice = ' '
/   end-for
/
/   syspinfo.resource = 'screen02'
/   syspinfo.service = '*display'
/   syspinfo.refresh = '*yes'
/   syspinfo.command = ''
/   screen02.sdfplist-numrow = size('screen02.elemlist')
/   screen02.file-menu=0
/   screen02.file-choice=0
/   transmit-by-stream variable-name = screen02 -
/                     ,stream-name = presentation -
/                     ,control-var-name = syspinfo
/
/   if (   (syspinfo.std-header.returncode.maincode == 'IDH0004') -
/       or (syspinfo.std-header.returncode.maincode == 'IDH0008'))
/      maincode = 'FHSEXIT'
/      goto end
/   end-if
/
/   if (syspinfo.std-header.returncode.maincode ne 'IDH0000')
/      sub2 = syspinfo.std-header.returncode.subcode2
/      sub1 = syspinfo.std-header.returncode.subcode1
/      main = syspinfo.std-header.returncode.maincode
/      write-text 'Error &sub2 &sub1 &main returned by FHS server'
/      maincode = 'FHS0ERR'
/      goto end
/   end-if
/
/   if screen02.file-menu ne 0
/      if screen02.file-choice == 9
/         maincode = 'FHS0RET'
/         goto end
/      else
/         for i = *counter(1,size('screen02.sdfplist-modindex')), -
             /cond=(screen02.sdfplist-modindex#i ne 0)
/            screen02-curr-index = screen02.sdfplist-modindex#i
/            if screen02.elemlist#screen02-curr-index.choice == '/'
/               element = screen02.elemlist#screen02-curr-index.elem
/               version = screen02.elemlist#screen02-curr-index.version
/               type    = screen02.elemlist#screen02-curr-index.type
/               if screen02.file-choice == 1 "delete element"
/                  assign-sysout to = *variable(sysout)
/                  resume-program
//                 delete-element element = *library-element -
//                                            ( library = *std -
//                                            , element = &element.
//                                                ( version = &version. ) -
//                                            , type = &type. )
/                  hold-program
/                  assign-sysout *primary
/               else-if screen02.file-choice == 2 "edit element"
/                  assign-sysout to = *variable(sysout)
/                  resume-program
//                 edit-element element = *library-element -
//                                            ( library = *std -
//                                            , element = &element. -
//                                                ( version = &version. ) -
//                                            , type = &type. )
/                  hold-program
/                  assign-sysout *primary
/               else-if screen02.file-choice == 3 "copy element"
/                  write-text 'Function not implemented'
/               else-if screen02.file-choice == 4 "print element"
/                  assign-sysout to = *variable(sysout)
/                  print-file *library-element -
/                                 ( library = &library. -
/                                 , element = &element. -
/                                     ( version = &version. ) -
/                                 , type = &type. )
/                  if-cmd-error
/                     error-on-print = true
/                  end-if
/                  assign-sysout *primary
/               else-if screen02.file-choice == 5 "select element"
/                  assign-sysout to = *variable(sysout)
/                  resume-program
//                 extract-element element = *library-element -
//                                            ( library = *std -
//                                            , element = &element. -
//                                                ( version = &version. ) -
//                                            , type = &type. ) -
//                                ,to-file = *std
/                  hold-program
/                  assign-sysout *primary
/               else-if screen02.file-choice == 6 "add element"
/                  write-text 'Function not implemented'
/               end-if
/
/               if ( error-on-print )
/                  show-variable sysout, information = *parameters( name = 
*none )
/                  maincode = 'PRT0ERR'
/                  goto end
/               end-if
/
/               if ( stmt-spinoff() == 'YES' )
/                  show-variable sysout, information = *parameters( name = 
*none )
/                  maincode = 'LMS0ERR'
/                  goto end
/               end-if
/            end-if
/         end-for
/      end-if
/   end-if
/
/   if (syspinfo.command ne '')
/      exec-cmd cmd=(&(syspinfo.command)) -
/              ,text-output=*none -
/              ,returncode=*variable(subcode2=sub2 -
/                                   ,subcode1=sub1 -
/                                   ,maincode=main)
/
/      if (sub1 ne 0)
/         write-text 'Error &sub2 &sub1 &main returned by command server'
/         maincode = 'CMD0ERR'
/         goto end
/      end-if
/   end-if
/end-while
/
/
/end:
/if (   (maincode = 'CMD0ERR') -
/    or (maincode = 'PRT0ERR') -
/    or (maincode = 'LMS0ERR') -
/    or (maincode = 'FHS0ERR') -
/   )
/   exit-procedure error = *yes(subcode2 = 0 -
/                              ,subcode1 = 64 -
/                              ,maincode = STOPERR)
/else-if (maincode = 'FHSEXIT')
/   exit-procedure error = *yes(subcode2 = 0 -
/                              ,subcode1 = 0  -
/                              ,maincode = STOP0OK)
/else-if (maincode = 'FHS0RET')
/   exit-procedure
/else
/   write-text 'Error &(sc2()) &(sc1()) &(mc()) reported'
/   exit-procedure error = *yes(subcode2 = 0 -
/                              ,subcode1 = 64 -
/                              ,maincode = STOPERR)
/end-if

Assuming that FHS-PRIV is loaded, the library manager can be called as follows:

/CALL-PROCEDURE FROM-FILE=*LIBRARY-ELEMENT(LIBRARY-MANAGER.PL, RUN)

A screen display should then appear (making use of SCREEN01), listing the names of the libraries which are held under the ID, e.g.:

It is now possible to open the listed libraries, and request a display of the appropriate elements. To do so, identify the library to be opened by marking the start of the corresponding line with a “/”; press the tab key to move the cursor into the “FILE” field (top left);

press the key, and enter “1” into the pull-down menu which then appears.

The screen output below should clarify this:

If the key is now pressed again, then another screen appears (making use of SCREEN02) in which is output the appropriate names of the elements in this library (together with the dates and times of their creation, their types, etc.).

A further option at this point is to process any of the listed elements. To do so, identify the element to be processed (e.g. PHKEY) by marking the start of the corresponding line with a “/”; press the tab key to move the cursor into the “FILE” field (top left); press the key, and enter into the pull-down menu which now appears the number which corresponds to the required processing for the element (e.g. “4” to print it out).

If the key is now pressed, the required action will be performed.
So much for the possible applications. Pressing the key exits from the library manager or returns to the initial menu.

Incidentally, it is possible to scroll the display by entering “+” or “-” in the “COMMAND” line to the right of the arrow. There is a Help menu which can be called up by pressing the key.