Dynamic help text maintenance

Date:Archived
Product/Release:LANSA for the AS/400
Abstract:UPDATE or ADD Help Text to fields within an application whilst the application was running
Submitted By:External

To be able to UPDATE or ADD HELP TEXT to fields within an application whilst the application was running without having to navigate the LANSA developers menu.

Enable another key on each DISPLAY(Obviously would work on REQUEST & POP_UP too) panel (F2 in my example (1) below) then test for F2 being used immediately following...

A further improvement may be to condition the key so that it is only show (for example) based on the value of a data area flag or a specific user id.

GROUP_BY       #PANEL FIELDS(<<Put your fields here);
DISPLAY        FIELDS(#PANEL) CHANGE_KEY(*YES) USER_KEYS((02 'Edt Help'));
* *********     Note that CURLOC$FN must be defined in dictionary
               (*CHAR 10);
IF             COND('#IO$KEY = ''02''');
EXECUTE        EDIT_HELP WITH_PARMS(#CURLOC$FN *BLANKS DF);
ENDIF;
* *********     Subroutine to deal with retrieval / editing of HELP;
DEFINE         #WRK_OBJNM REFFLD(#CURLOC$FN);
DEFINE         #WRK_OBJEX REFFLD(#CURLOC$FN);
DEFINE         #WRK_OBJTP TYPE(*CHAR) LENGTH(2) REFFLD(*NONE)
               DEFAULT('DF');
SUBROUTINE     EDIT_HELP PARMS((#WRK_OBJNM *RECEIVED)
               (#WRK_OBJEX *RECEIVED) (#WRK_OBJTP *RECEIVED));
* *********     If no name received, assume Process/Function help...;
IF             COND('#WRK_OBJNM = *BLANKS');
CHANGE         #WRK_OBJNM *FUNCTION;
CHANGE         #WRK_OBJEX *PROCESS;
CHANGE         #WRK_OBJTP PF;
ENDIF;
EXCHANGE       FIELDS(#WRK_OBJNM #WRK_OBJEX #WRK_OBJTP);
CALL           PROCESS(*DIRECT) FUNCTION(UTHELP) EXIT_USED(*NEXT) MENU
               USED(*NEXT);
ENDROUTINE;

The source of the function that gets called looks like this...

Function : UTHELP
* ********* *******************************************************
Function which can be used to retrieve and change help and can be attached
temporarily to a function with a command key - to, for example, 
enable users to directly modify HELP text. Written by Tony GASKIN, August 1998;
* ******************************************************;
FUNCTION      OPTIONS(*DIRECT);
DEFINE        #WRK_OBJNM REFFLD(#CURLOC$FN) DESC('Object name');
DEFINE        #WRK_OBJEX REFFLD(#CURLOC$FN) DESC('Object Extension');
DEFINE        #WRK_OBJTP TYPE(*CHAR) LENGTH(2) DESC('Object Type')
              DEFAULT('DF');
DEFINE        #WRK_OBJLN TYPE(*CHAR) LENGTH(77) COLHDG('HELP Text...')
              INPUT_ATR(LC);
DEFINE        #WRK_TEST TYPE(*CHAR) LENGTH(10) TO_OVERLAY(#WRK_OBJLN);
DEF_LIST      #WRK_WLST FIELDS((#WRK_OBJLN)) COUNTER(#LISTCOUNT)
              TYPE(*WORKING) ENTRYS(250);
DEF_LIST      #WRK_DLST FIELDS((#WRK_OBJLN));
* *********    Check if main parameter passed;
IF            COND('#WRK_OBJNM = *BLANKS');
MESSAGE       MSGTXT('No name supplied');
RETURN;
ENDIF;
* *********    Retrieve HELP from LANSA's internals...;
CLR_LIST      #WRK_WLST;
USE           GET_HELP WITH_ARGS(#WRK_OBJNM #WRK_OBJEX #WRK_OBJTP)
              TO_GET(#WRK_WLST #IO$STS);
IF            COND('#IO$STS = ER');
MESSAGE       MSGTXT('Serious error occurred retrieving HELP');
RETURN;
ENDIF;
* *********    Working to display list...;
CLR_LIST      #WRK_DLST;
SELECTLIST    #WRK_WLST;
IF            COND('#WRK_TEST = ''$$LANGUAGE''');
IF            COND('#WRK_TEST2 = LASTWASTOO');
DEFINE        #WRK_OBJL2 REFFLD(#WRK_OBJLN);
CHANGE        #WRK_OBJL2 #WRK_OBJLN;
CHANGE        #WRK_OBJLN *BLANKS;
* *********    Add 20 blank lines following a $$LANGUAGE keyword;
BEGIN_LOOP    FROM(1) TO(20);
ADD_ENTRY     #WRK_DLST;
END_LOOP;
CHANGE        #WRK_OBJLN #WRK_OBJL2;
ENDIF;
ENDIF;
ADD_ENTRY     #WRK_DLST;
IF            COND('#WRK_TEST = ''$$LANGUAGE''');
DEFINE        #WRK_TEST2 TYPE(*CHAR) LENGTH(10);
CHANGE        #WRK_TEST2 LASTWASTOO;
ELSE;
CHANGE        #WRK_TEST2 *BLANKS;
ENDIF;
ENDSELECT;
* *********    20 blank records to the end of the list...;
CHANGE        #WRK_DLST *DEFAULT;
BEGIN_LOOP    FROM(1) TO(20);
ADD_ENTRY     #WRK_DLST;
END_LOOP;
* *********    Auto set to change if text is new...;
IF            COND('#LISTCOUNT = *ZERO');
SET_MODE      *CHANGE;
ELSE;
SET_MODE      *DISPLAY;
ENDIF;
* *********;
DISPLAY       FIELDS((#WRK_OBJNM *L3 *P2 *OUT)
              (#WRK_OBJEX *L3 *P36 *NOID *OUT)(#WRK_OBJTP *L3 *P56 *OUT))
              DESIGN(*DOWN) IDENTIFY(*DESC)DOWN_SEP(001) ACROSS_SEP(001)
              BROWSELIST(#WRK_DLST) EXIT_KEY(*NO)
              CHANGE_KEY(*YES) PROMPT_KEY(*NO);
IF_MODE       *CHANGE;
CLR_LIST      #WRK_WLST;
SELECTLIST    #WRK_DLST GET_ENTRYS(*NOTNULL);
ADD_ENTRY     #WRK_WLST;
ENDSELECT;
USE           PUT_HELP WITH_ARGS(#WRK_OBJNM #WRK_OBJEX #WRK_OBJTP
              #WRK_WLST) TO_GET(#IO$STS);
IF            COND('#IO$STS = OK');
MESSAGE       MSGTXT('HELP updated successfully');
ELSE;
MESSAGE       MSGTXT('Problems occurred writing HELP - seek advice');
ENDIF;
ENDIF;
RETURN;