SYLSTALTSP: PGM PARM(&WORD) DCL VAR(&WORD) TYPE(*CHAR) LEN(32) /*------ ------*/ /* */ /* The VARRCD buffer areas... */ /* */ DCL VAR(&DATTIMBUF) TYPE(*CHAR) LEN(128) DCL VAR(&CHKWORDBUF) TYPE(*CHAR) LEN(128) DCL VAR(&DCTBUF) TYPE(*CHAR) LEN(128) DCL VAR(&WORDBUF) TYPE(*CHAR) LEN(128) DCL VAR(&NPDCTBUF) TYPE(*CHAR) LEN(128) /*------ ------*/ /* */ /* UIM control fields... */ /* */ /* The 'application handle'... */ DCL VAR(&APPHND) TYPE(*CHAR) LEN(8) /* The 'list handle'... */ DCL VAR(&LSTHND) TYPE(*CHAR) LEN(4) /* The 'redisplay option' for a displayed panel... */ DCL VAR(&REDSPOPT) TYPE(*CHAR) LEN(4) /* The function-requested return code from the displayed panel... */ DCL VAR(&FUNCTION) TYPE(*CHAR) LEN(4) DCL VAR(&FUNC_NBR) TYPE(*DEC) LEN(6) /*------ ------*/ /* */ /* Spelling Aid API command parameters... */ /* */ /* The word to check for alternates against... */ DCL VAR(&CWORD) TYPE(*CHAR) LEN(32) /* The 'misspelled word' indicator... */ DCL VAR(&MISSPELL) TYPE(*CHAR) LEN(1) /* The count of dictionaries alternates were found in... */ DCL VAR(&DICT_CT) TYPE(*DEC) LEN(1) /* The list of dictionaries alternates were found in... */ DCL VAR(&DICT_LST) TYPE(*CHAR) LEN(160) /* The count of words in the alternate-words list... */ DCL VAR(&WORD_CT) TYPE(*DEC) LEN(5) /* The alternate-words list... */ DCL VAR(&WORD_LST) TYPE(*CHAR) LEN(3000) /*------ ------*/ /* */ /* Various work areas and fields... */ /* */ /* The address pointer into the returned-dictionary list... */ DCL VAR(&D_ADDR) TYPE(*DEC) LEN(3) /* The current alternate word from the list... */ DCL VAR(&CUR_WORD) TYPE(*CHAR) LEN(32) /* The list position pointer for the current dictionary segment... */ /* This is the number of the segment in the returned word list...*/ /* This number has a max value of DICT_CT and is used mostly to */ /* determine whether NXT/PRV is available at any given time... */ DCL VAR(&DICT_PTR) TYPE(*DEC) LEN(3) VALUE(0) /* The table of offsets for dictionary segments of the word list.. */ DCL VAR(&DICT_OS) TYPE(*CHAR) LEN(32) + VALUE(X'00000000000000000000000000000000000+ 00000000000000000000000000000') /* + Initialize to binary zeros... */ /* The address of the current dictionary in the table of offsets...*/ DCL VAR(&DOS_ADDR) TYPE(*DEC) LEN(3) /* The list position pointer for the current word... */ DCL VAR(&WORD_PTR) TYPE(*DEC) LEN(5) VALUE(0) /* The length of the current word in the word list... */ DCL VAR(&WD_WLEN) TYPE(*DEC) LEN(3) /* The address pointer into the word list... */ DCL VAR(&WD_ADDR) TYPE(*DEC) LEN(5) /* The word list word counter... */ DCL VAR(&WD_WC) TYPE(*DEC) LEN(3) /* The dictionary number that this word list segment is for... */ /* This is the number of the dictionary entry in DICT_LST... */ DCL VAR(&DCT_NBR) TYPE(*DEC) LEN(3) /* NXT/PRV requested constants... */ DCL VAR(&PRV_REQD) TYPE(*DEC) LEN(3) VALUE(7) DCL VAR(&NXT_REQD) TYPE(*DEC) LEN(3) VALUE(8) /* The system date and time for the list head separator... */ DCL VAR(&SYSDATE) TYPE(*CHAR) LEN(6) DCL VAR(&DATE) TYPE(*CHAR) LEN(7) DCL VAR(&SYSTIME) TYPE(*CHAR) LEN(6) /* NEXT and PREV dictionary request indicators... */ DCL VAR(&NXT_DICT) TYPE(*CHAR) LEN(1) DCL VAR(&PRV_DICT) TYPE(*CHAR) LEN(1) /* Address item work field... */ DCL VAR(&WRK_ADDR) TYPE(*DEC) LEN(5) /*------------------------------------------------------------------*/ /* Grab the word from the input PARM... */ CHGVAR VAR(&CWORD) VALUE(&WORD) /*------ ------*/ /* */ /* Pass the word through the Spelling Aid API... */ /* */ SPLAID WORD(&CWORD) SPLCHK(&MISSPELL) + NBRDCTRTN(&DICT_CT) DCTRTNLST(&DICT_LST) + NBRWRDRTN(&WORD_CT) WRDRTNLST(&WORD_LST) MONMSG MSGID(CPF9898) EXEC(SNDPGMMSG MSGID(CPF9898) + MSGF(QCPFMSG) MSGDTA('Error in "Spelling + Aid" internal function. Check job log for + details') MSGTYPE(*ESCAPE)) /*------ ------*/ /* Initialize NXT/PRV indicators based on dictionary count... */ /* PRV is always initialized for "no previous"... */ /* NXT is initialized to "no next" only if count is 1 or less... */ CHGVAR VAR(&PRV_DICT) VALUE('0') IF COND(&DICT_CT *GT 1) THEN(CHGVAR + VAR(&NXT_DICT) VALUE('1')) ELSE CMD(CHGVAR VAR(&NXT_DICT) VALUE('0')) /* */ /* Open the UIM Display Application... */ /* */ OPNDSPAPP APPHND(&APPHND) PNLGRP(*LIBL/SASPA) /* */ /* Save the existing screen image so UIM knows how to create a */ /* window area and restore after we're done... */ /* */ SETSCRIMG APPHND(&APPHND) /* */ /* Add a pop-up window work-area for UIM... */ /* */ ADDPOPWDW APPHND(&APPHND) COLUMN(10) /* Initialize dictionary and word list address pointers... */ CHGVAR VAR(&DICT_PTR) VALUE(1) CHGVAR VAR(&WD_ADDR) VALUE(1) /*------ ------*/ /* */ /* Set Date/Time heading VARRCD... */ /* */ RTVSYSVAL SYSVAL(QDATE) RTNVAR(&SYSDATE) CVTDAT DATE(&SYSDATE) TOVAR(&DATE) FROMFMT(*SYSVAL) + TOFMT(*CYMD) TOSEP(*NONE) RTVSYSVAL SYSVAL(QTIME) RTNVAR(&SYSTIME) CHGVAR VAR(&DATTIMBUF) VALUE(&DATE) CHGVAR VAR(%SST(&DATTIMBUF 8 6)) VALUE(&SYSTIME) /* */ /* Put the Date/Time VARRCD into the variable pool... */ /* */ PUTDLGVAR APPHND(&APPHND) VARBUF(&DATTIMBUF) + VARBUFLEN(13) VARRCDNAM(DATETIME) /*------ ------*/ /* */ /* Set Supplied Word VARRCD... */ /* */ CHGVAR VAR(&CHKWORDBUF) VALUE(&CWORD) /* */ /* Put the Date/Time VARRCD into the variable pool... */ /* */ PUTDLGVAR APPHND(&APPHND) VARBUF(&CHKWORDBUF) + VARBUFLEN(32) VARRCDNAM(CHKWORD) /*------ ------*/ /* Initialize word position pointer for this segment... */ REQD_DICT: CHGVAR VAR(&WORD_PTR) VALUE(0) /* */ /* Set the PRV/NXT dictionary/library VARRCD... */ /* */ CHGVAR VAR(&NPDCTBUF) VALUE(&NXT_DICT) CHGVAR VAR(%SST(&NPDCTBUF 2 1)) VALUE(&PRV_DICT) /* */ /* Put the Dictionary/Library VARRCD into the variable pool... */ /* */ PUTDLGVAR APPHND(&APPHND) VARBUF(&NPDCTBUF) + VARBUFLEN(2) VARRCDNAM(NPDICT) /*------ ------*/ /* In order to process NXT/PRV requests quickly, we'll always */ /* stash WD_ADDR for the start of a word list dictionary segment */ /* into a table of offsets. We can then back up as many segments */ /* as are requested (or jump forward) without having to locate */ /* the segment start... */ CHGVAR VAR(&DOS_ADDR) VALUE(1 + ((&DICT_PTR - 1) * 4)) /* Let's see if an address has been stashed there for this */ /* dictionary on a previous cycle. If so, use it; otherwise */ /* stash the current WD_ADDR into it... */ CHGVAR VAR(&WRK_ADDR) VALUE(%BIN(&DICT_OS &DOS_ADDR + 4)) /* Check for a non-zero address and use it if it is... */ IF COND(&WRK_ADDR *NE 0) THEN(CHGVAR + VAR(&WD_ADDR) VALUE(&WRK_ADDR)) /* ...stash WD_ADDR for possible later recall... */ ELSE CMD(CHGVAR VAR(%BIN(&DICT_OS &DOS_ADDR 4)) + VALUE(&WD_ADDR)) /* */ /* Gets this dictionary number from returned word list... */ /* */ CHGVAR VAR(&DCT_NBR) VALUE(%BIN(&WORD_LST &WD_ADDR 4)) /* */ /* Get the current dictionary/library from the list... */ /* */ CHGVAR VAR(&D_ADDR) VALUE(1 + ((&DCT_NBR - 1) * 20)) /* Set the VARRCD for dictionary/library... */ CHGVAR VAR(&DCTBUF) VALUE(%SST(&DICT_LST &D_ADDR 20)) /* */ /* Place the dict/lib VARRCD into the variable pool... */ /* */ PUTDLGVAR APPHND(&APPHND) VARBUF(&DCTBUF) + VARBUFLEN(20) VARRCDNAM(CURDICTLIB) /*------ ------*/ /* */ /* Gets word count for this dictionary from returned word list... */ /* */ CHGVAR VAR(&WD_ADDR) VALUE(&WD_ADDR + 4) CHGVAR VAR(&WD_WC) VALUE(%BIN(&WORD_LST &WD_ADDR 4)) /* */ /* Gets to the length of the first word in this segment... */ /* */ CHGVAR VAR(&WD_ADDR) VALUE(&WD_ADDR + 4) /*------ ------*/ NEXT_WORD: CHGVAR VAR(&WD_WLEN) VALUE(%BIN(&WORD_LST &WD_ADDR 4)) /* */ /* Gets this word from returned word list... */ /* */ CHGVAR VAR(&WD_ADDR) VALUE(&WD_ADDR + 4) /* */ /* Extract the current word from the word list... */ /* */ CHGVAR VAR(&CUR_WORD) VALUE(%SST(&WORD_LST &WD_ADDR + &WD_WLEN)) /* */ /* Set address pointer after end of current word... */ /* */ CHGVAR VAR(&WD_ADDR) VALUE(&WD_ADDR + &WD_WLEN) /*------ ------*/ /* */ /* Set the word list VARRCD... */ /* */ CHGVAR VAR(&WORDBUF) VALUE(&CUR_WORD) /* */ /* ...and add this current alternate-spelling word to the list... */ /* */ ADDLSTE APPHND(&APPHND) VARBUF(&WORDBUF) + VARBUFLEN(32) VARRCDNAM(ALTWORDLE) + LSTNAM(SPALIST) LSTEHND(&LSTHND) /*------ ------*/ /* */ /* Set our word pointer up to the next word... */ /* */ CHGVAR VAR(&WORD_PTR) VALUE(&WORD_PTR + 1) /* */ /* As long as the word pointer is less than the word count for */ /* this dictionary, keep looping back... */ /* */ IF COND(&WORD_PTR *LT &WD_WC) THEN(GOTO + CMDLBL(NEXT_WORD)) /*------ ------*/ /*------ ------*/ /* */ /* This instance of the list is built and all VARRCDs have been */ /* PUT, so display the panel... */ /* */ /* Initialize the redisplay option... */ CHGVAR VAR(&REDSPOPT) VALUE(*NO) /* ...and display the panel... */ DSPPNL APPHND(&APPHND) FUNCTION(&FUNCTION) + PNLNAM(SPA) REDSPOPT(&REDSPOPT) /* */ /* Retrieve the function-requested return code... */ /* */ CHGVAR VAR(&FUNC_NBR) VALUE(%BIN(&FUNCTION 1 4)) /*------ ------*/ /* */ /* Get rid of the current list so we can start the next one for */ /* the next dictionary... */ /* */ DLTLST APPHND(&APPHND) LSTNAM(SPALIST) /*------ ------*/ /* */ /* If an exit-type function was requested, then get out... */ /* */ IF COND(&FUNC_NBR *LT 0) THEN(GOTO + CMDLBL(EXIT_APP)) /*------ ------*/ /* Otherwise, set up for a redisplay... */ CHGVAR VAR(&REDSPOPT) VALUE(*YES) /* Check NXT/PRV function requests... */ /* Bump to the next segment count... */ IF COND(&FUNC_NBR *EQ &NXT_REQD) THEN(CHGVAR + VAR(&DICT_PTR) VALUE(&DICT_PTR + 1)) /* Drop to the previous segment count... */ ELSE CMD(IF COND(&FUNC_NBR *EQ &PRV_REQD) + THEN(CHGVAR VAR(&DICT_PTR) + VALUE(&DICT_PTR - 1))) /* See if we've reached the last available... */ IF COND(&DICT_PTR *GE &DICT_CT) THEN(CHGVAR + VAR(&NXT_DICT) VALUE('0')) ELSE CMD(CHGVAR VAR(&NXT_DICT) VALUE('1')) /* ...and see if we've reached the first available... */ IF COND(&DICT_PTR *LE 1) THEN(CHGVAR + VAR(&PRV_DICT) VALUE('0')) ELSE CMD(CHGVAR VAR(&PRV_DICT) VALUE('1')) /* */ /* Loop back to access the segment for the requested dictionary... */ /* */ GOTO CMDLBL(REQD_DICT) /*------ ------*/ /*------------------------------------------------------------------*/ /* Main exit for this application... */ /*------------------------------------------------------------------*/ /* */ /* Close the UIM application... */ /* */ EXIT_APP: CLOAPP APPHND(&APPHND) RCLRSC /* */ /* If EXIT was requested, send appropriate *COMP message... */ /* */ IF COND(&FUNC_NBR *EQ -4) THEN(SNDPGMMSG + MSGID(SYU8010) MSGF(SYUSRSYS/SYUSRMSG) + MSGTYPE(*NOTIFY)) /* */ /* If CANCEL was requested, send appropriate *COMP message... */ /* */ ELSE CMD(IF COND(&FUNC_NBR *EQ -8) THEN(SNDPGMMSG + MSGID(SYU8011) MSGF(SYUSRSYS/SYUSRMSG) + MSGTYPE(*NOTIFY))) RETURN ENDPGM