<






Status Bar


stsbar.gif (16998 bytes)

The animation above was composed from actual AS/400 screen images.

The status-bar rendering is accomplished by using status messages. To use the command just insert it into your CL programs or call the program directly from with your RPG programs.

The CL program listed below will enable you to include a status bar into your long-running jobs.

PGM                     PARM(&PC)
DCL                      VAR(&PC) TYPE(*DEC) LEN(3 0)
DCL                      VAR(&PC@) TYPE(*CHAR) LEN(3)
DCL                      VAR(&NI) TYPE(*CHAR) LEN(1) VALUE(X'20')
DCL                      VAR(&RI) TYPE(*CHAR) LEN(1) VALUE(X'33')
DCL                      VAR(&RI2) TYPE(*CHAR) LEN(1) VALUE(X'23')
DCL                      VAR(&BAR) TYPE(*CHAR) LEN(40)
DCL                      VAR(&X) TYPE(*DEC) LEN(3 0)
DCL                      VAR(&Y) TYPE(*DEC) LEN(2 0)
DCL                      VAR(&WK20) TYPE(*CHAR) LEN(17)

CHGVAR               VAR(&X) VALUE((&PC / 100) * 40)
CHGVAR               VAR(&Y) VALUE((&X / 2) - 2)
IF                        COND(&X *LE 0 *OR &Y *LE 0) THEN(RETURN)
CHGVAR               VAR(&BAR) VALUE(' ')
CHGVAR               VAR(&PC@) VALUE(&PC)
IF                         COND(%SST(&PC@ 1 1) = '0') THEN(CHGVAR +
                          VAR(%SST(&PC@ 1 1)) VALUE(' '))
CHGVAR               VAR(%SST(&BAR &Y 3)) VALUE(&PC@)
CHGVAR               VAR(&Y) VALUE(&Y +3)
CHGVAR               VAR(%SST(&BAR &Y 1)) VALUE('%')
CHGVAR               VAR(%SST(&BAR &X 1)) VALUE(&RI2)
CHGVAR               VAR(%SST(&BAR 40 1)) VALUE(&NI)
SNDPGMMSG       MSGID(CPF9897) MSGF(QCPFMSG) MSGDTA(&WK20 || +
                              &RI || &BAR) TOPGMQ(*EXT) MSGTYPE(*STATUS)
RETURN 

The Command source for STATUSBAR is listed below:

CMD                      PROMPT('Status Bar Display')
                           PARM KWD(PERCENT) TYPE(*DEC) LEN(3 0) RANGE(1 +
                           100) MIN(1) PROMPT('Percentage Complete')

The rendering of the Command looks as follows:

                                           Status Bar Display (STATUSBAR)

Type choices, press Enter.

Percentage Complete . . . . . . PERCENT ____

In RPG you can determine the number of records in a file at open time by referencing the file's File Information Data Structure (INFDS), as follows:

     Iinfds                                DS
     I                                                          B 156 1590#RCDS

Using simple arithmetic it is possible to compute how much of the file has been processed and activate STATUSBAR with the appropriate percentage complete value.

A complete sample program that uses the STATUSBAR command is detailed below:

***************************************************
* A program to demonstrate the STATUSBAR
* Written by: Trevor Seeney
* Date: September 1996
* SENTINEX INC.
***************************************************
FANYFILE   IF     F         2000         DISK                    KINFDS FILEDS
*
IANYFILE           NS 01
IFILEDS             DS
I                                                  B 156 1590#RCDS
*
I                        'STATUSBAR'      C                   STSBAR
*
C                            READ ANYFILE LR
C           *INLR        DOWEQ*OFF
*
C                            EXSR DSPSTS
*
* User code goes here
*
*
*
C                            READ ANYFILE LR
C                            ENDDO
*
*************************************************
*
C                 DSPSTS               BEGSR
*
C                                           ADD    1               RRN#               80
C                 RRN                    # MULT 100       WRK
C                 WRK DIV            #RCDS                PC                     30H
C                 PC                       DIV     5               WRK                  80
C                                           MVR                  REM                   10
C                 PC                       IFLE    5
C                 PC                       ORGE 95
C                 REM                    OREQ 0
C                                           CALL STSBAR
C                                           PARM                 PC
C                                           ENDIF
C                                           ENDSR
*



Home | Software Solutions | iSeries Security | Tips & Techniques | Consulting | About us | Contact Us




Sentinex Inc.
379 Hamilton Drive
Stewartsville, NJ, 08886

Telephone: (800) 822 1004
Outside USA: (908) 213 8650
FAX: (908) 213 8652
e-Mail: info@sentinex.com
Member of PartnerWorld for Developers
IBM is a registered trademark of IBM Corporation.