subroutine kb_entry_sub_ar(parm) /************************ PURPOSE : Provides processing support for the knowledgeBase entry window - KB_ENTRY. CREATED : 01-22-93 PROCEDURES : Callable from the KB_ENTRY window. Single parameter required indicating processing action to take. WARNINGS : Requires the existence of the following tables and indexes: Tables.: SYSKNOWLEDGEBASE !SYSKNOWLEDGEBASE Indexes: SEARCH_XREF in the SYSKNOWLEDGEBASE table REVISION HISTORY (Most CURRENT first) : DATE IMPLEMENTOR FUNCTION -------- ----------- --------------------------------------------------- 01-22-93 kb Wrote initial code 05-13-93 tmc Added this header. Cleaned up code to conform to standards. Removed hardcoded names to equates at top of routine. Made version 3.x specific. *************************/ * COMMON Variables (Terminate with '%') : $insert sysinclude, window_common% * EQUATE Variables (Terminate with '$') : equ progName$ to 'KB_ENTRY_SUB_AR' equ transferTable$ to 'KNOWLEDGE_TRANSFER' equ true$ to 1 equ false$ to 0 equ yes$ to 1 equ no$ to 0 equ otherwise$ to 1 equ null$ to '' equ keyList$ to 1 ; * key_opt option return values/actions equ allDocs$ to 2 equ search$ to 3 equ all$ to 1 ; * upload/download options return values/actions equ some$ to 2 equ subList$ to 'KEY_OPT,PRINT,UPLOAD,DOWNLOAD' equ delim$ to \2C\ ; * comma * VARIABLES : pos = 0 ; * generic list/array index counter col = 2 ; * default screen coordinates (columns) row = 2 disp = null$ format = null$ mode = 'R' select = null$ title = null$ attr = null$ help = null$ coord = null$ type = null$ retVal = null$ ixSearchStr = 'SYSKNOWLEDGE*SEARCH_XREF*DOC_ID,TITLE*KEY' temp = null$ volume = null$ options = null$ table = null$ * MESSAGES Called (Terminate with '$') : equ createTableFail$ to 'W506' equ insertDisk$ to 'I100' equ invalBranch$ to "|Invalid branch ('%1%') passed to %2%!|Process canceled.|" equ noDocs$ to "|There are no documents selected.|Process canceled.|" equ docsSelected$ to "|There are %1% documents selected for printing.|Would you like to continue?|" equ tableExists$ to "|%1% already exists.|Do you want to download into %1%?|" equ drvNotReady$ to "|Insert disk in drive %1%|and close the drive door.|" equ createTable$ to '|Creating "%1%" on "%2%".|Please wait.|' * DECLARED FUNCTIONS Called declare function pop.up, drvReady, lastKey * DECLARED SUBROUTINES Called declare subroutine attachTable_sub, catalyst, copyRow_sub, fsMsg declare subroutine makeTable_sub, make.list, msg, detachTable_sub * * * * * * * * * * * * * * * * * * * * * * * * * PROGRAM TOP locate parm in subList$ using delim$ setting pos then on pos gosub key_opt, print, upload, download end else msg( invalBranch$, null$, null$, parm : @vm : progName$ ) end return * * * * * * * * * * * * * * * * * * * * * * * * * INTERNAL SUBROUTINES key_opt: disp = 'Current List':@FM:'All Documents':@FM:'Keyword Search' format = '1:25:L::' title = 'Document Options' type = 'P' retVal = pop.up( col, row, table, disp, format, mode, select, title, attr, help, coord, type ) begin case case retVal = keyList$ * gives a popup of current browse list or all row in table retVal = null$ table = "SYSKNOWLEDGE" disp = wc_browse_list% format = '0:5:L::Key\1:70:L::Title' mode = 'T' select = 1 title = 'Documents' coord = 1 type = 'K' retVal = pop.up( col, row, table, disp, format, mode, select, title, attr, help, coord, type ) if retVal then if wc_browse_list% ne retVal then gosub setBrowseList end end case retVal = allDocs$ * gives a popup of all rows in the table retVal = null$ table = "SYSKNOWLEDGE" disp = null$ format = '0:5:L::Key\1:70:L::Title' mode = 'T' select = 1 title = 'Documents' coord = 1 type = 'K' retVal = pop.up( col, row, table, disp, format, mode, select, title, attr, help, coord, type ) if retVal then if wc_browse_list% ne retVal then gosub setBrowseList end end case retVal = search$ catalyst( 'B', ixSearchStr ) end case return * * * * * * * * * * * * * * * * * * * * * * * * print: * * Print the current keylist. * if wc_browse_list% then retVal = yes$ msg( docsSelected$, 'BNY', retVal, wc_xCnt% ) if retVal then retVal = wc_browse_list% convert @vm to " " in retVal perform 'MERGE KB_PRINT ' : retVal : ' (P' end end else msg( noDocs$,'T1' ) end return * * * * * * * * * * * * * * * * * * * * * * * * upload: * * Upload new data to the knowledgebase. * loop gosub getVolume if attachFlag then attachtable_sub( volume, table, options ) if @file.error< 1 > = 400 then @file.error = null$ if @file.error then fsmsg() end else temp = volume volume = null$ end end else * two exit pts...bad but fast return end while volume repeat disp = 'All Documents':@FM:'Selected Documents' format = '1:25:L::' title = 'Upload options' type = 'P' retVal = null$ table = null$ retVal = pop.up( col, row, table, disp, format, mode, select, title, attr, help, coord, type ) table = transferTable$ if retVal then begin case case retVal = all$ retVal = '*' case retVal = some$ disp = null$ format = '0:5:L::Key\1:70:L::Title' mode = 'T' select = 1 title = 'Select items to Update KnowledgeBase' coord = 1 type = "K" retVal = pop.up( col, row, '@' : table, disp, format, mode, select, title, attr, help, coord, type ) convert @vm to @fm in retVal end case if retval then * append a null to retVal to keep copyrow_sub from eating it. copyrow_sub( table, retVal:"", wc_dataFile%, null$, null$ ) convert @fm to @vm in retVal if retVal = '*' else gosub setBrowseList end end end return * * * * * * * * * * * * * * * * * * * * * * * * download: * * Download the knowledgebase or a subset of it to a new file. This is used * for the submission process for new entries into the knowledgebase. * if wc_browse_list% then loop gosub getVolume if attachflag then msg( createTable$, 'UB', retVal, table : @fm : volume ) maketable_sub( volume, table : '*GLOBAL', null$, null$, attachFlag ) msg( null$, 'DB', retVal ) if @file.error then if @file.error< 1 > = createTableFail$ then retVal = yes$ msg( tableExists$, 'BNY', retVal, field( table, '*', 1 ) ) if retVal then volume = null$ end end else fsmsg( ) end end else temp = volume volume = null$ end end while volume repeat if wc_browse_list% then srcIds = wc_browse_list% convert @vm to @fm in srcIds end else srcIds = @ans end if volume then copyrow_sub( wc_dataFile%, srcIds, field( table, '*', 1 ), null$, null$ ) detachtable_sub(temp, "", "") end end else msg( noDocs$, 'T1' ) end return * * * * * * * * * * * * * * * * * * * * * * * * setBrowseList: * * Build a browse list. * wc_browse_next% = retVal wc_new_browse% = true$ wc_reset% = 4 wc_xcnt% = count( wc_browse_next%, @vm ) + ( wc_browse_next% ne null$ ) return * * * * * * * * * * * * * * * * * * * * * * * * getVolume: * * Get volume of table to download/upload to/from. * volume = 'A:' attachFlag = false$ msg( insertDisk$, 'RC', volume ) if volume then table = transferTable$ if index( 'A:B:', volume, 1 ) then drv = 0 done = false$ loop done = drvReady( drv ) if done then attachFlag = true$ end else msg( drvNotReady$, null$, null$, char( 65 + drv ) ) end until done or lastKey() = @int.const<1> repeat end end return