Jump to content

Readline interface: Difference between revisions

→‎{{header|REXX}}: reduced the size of the program, added more commands. -- ~~~~
(→‎{{header|REXX}}: fixed a few bugs, added a "user" command. -- ~~~~)
(→‎{{header|REXX}}: reduced the size of the program, added more commands. -- ~~~~)
Line 147:
trace off /*suppress echoing of non-zero RC*/
signal on syntax; signal on novalue /*handle REXX program errors. */
cmds='?|Help|MANual CALendar DIR ECHO CALendarFC|FILECOMPAre FIND HISTory Kedit LLL PROMPT Quit Rexx REDO Type',
'LLL MEM MORE PROMPT Quit REMark Rexx REDO Type VER'
cmdX='CAL DIR ECHO FC FIND KEDIT LLL MEM MORE REM REXX TYPE VER'
cls='CLS' /*define the pgm to clear screen.*/
@hist.='*** command not defined. ***' /*initialize the history database*/
Line 153 ⟶ 155:
prompt='Enter command ──or── ? ──or── Quit' /*default PROMPT msg.*/
sw=linesize() /*some REXX don't have this BIF. */
callcls .CLS /*start with a clean slate. */
redoing=0 /*flag for executing naked ReDO.*/
redoing=0
 
do forever
call prompter; if xxx=='' then iterate
select /*now then, let's rock & roll. */
when wordpos(xxxF,cmdX)\=='CAL' 0 then call .calcmdX
when xxxF=='CLSHISTORY' then call .clshistory
when xxxF=='DIRHELP' then call .dirhelp
when xxxF=='ECHOPROMPT' then call .echoprompt
when xxxF=='HISTORYQUIT' then call .historyleave
when xxxF=='HELPREDO' then call .helpredo
whenotherwise xxxF=='KEDIT' call er 'unknown command:' xxx then call .kedityyy
when xxxF=='LLL' then call .lll
when xxxF=='PROMPT' then call .prompt
when xxxF=='QUIT' then leave
when xxxF=='REDO' then call .redo
when xxxF=='REXX' then call .rexx
when xxxF=='TYPE' then call .type
otherwise call er 'unknown command:' xxx yyy /*oops-say.*/
end /*select*/
end /*forever*/
Line 186 ⟶ 181:
condition('D'),'REXX source statement (line' sigl"):",,
sourceline(sigl)
/*──────────────────────────────────.CALCMDX subroutine─────────────────────subroutine────────────────────*/
.calcmdX: 'CAL'xxxF yyy; return
/*──────────────────────────────────.CLS subroutine─────────────────────*/
.cls: cls; return
/*──────────────────────────────────.DIR subroutine─────────────────────*/
.dir: 'DIR' yyy; return
/*──────────────────────────────────.ECHO subroutine────────────────────*/
.echo: 'ECHO' yyy; return
/*──────────────────────────────────.HELP subroutine────────────────────*/
.help: say center(strip(xxx yyy),sw-1,'═'); cmds_=cmds
cmdsH='CLS DIR ECHO FC FIND MEM MORE REM TYPE VER'
help. = ' No help is available for the' yyy "command."
help.cal = 'shows a calendar for the current month or specified month.'
Line 223 ⟶ 212:
end
return
/*──────────────────────────────────.KEDITPROMPT subroutine───────────────────subroutine──────────────────*/
.keditprompt: if yyyU\=='KEDIT' then prompt=yyy; return
/*──────────────────────────────────.LLL subroutine─────────────────────*/
.lll: 'LLL' yyy; return
/*──────────────────────────────────PROMPTER subroutine─────────────────*/
prompter: if redoing then do /*special case for naked REDO */
Line 242 ⟶ 229:
xxxF=unAbbrev(xxx) /*expand the abbreviation (maybe)*/
return
/*──────────────────────────────────.PROMPT subroutine──────────────────*/
.prompt: if yyyU\=='' then prompt=yyy; return
/*──────────────────────────────────.redo subroutine────────────────────*/
.redo:
Line 257 ⟶ 242:
@hist.yyy
return
/*──────────────────────────────────.REXX subroutine────────────────────*/
.rexx: 'REXX' yyy; return
/*──────────────────────────────────.TYPE subroutine────────────────────*/
.type: 'TYPE' yyy; return
/*──────────────────────────────────UNABBREV subroutine─────────────────*/
unabbrev: procedure; arg ccc
Line 266 ⟶ 247:
when abbrev('CALENDAR',ccc,3) then return 'CAL'
when abbrev('CLEARSCREEN',ccc,5) then return 'CLS'
when abbrev('FILECOMPARE',ccc,9) then return 'CLSFC'
when abbrev('HISTORY',ccc,4) then return 'HISTORY'
when abbrev('HELP',ccc,1) |,
abbrev('MANUAL',ccc,3) |,
ccc=='?' then return 'HELP'
when abbrev('KEDIT',ccc,1) then return 'KEDIT'
when abbrev('QUIT',ccc,1) then return 'QUIT'
when xxxF==abbrev('LLLREMARK' ,ccc,3) then callreturn .lll'REM'
when abbrev('REXX',ccc,1) then return 'REXX'
when abbrev('TYPE',ccc,1) then return 'TYPE'
Cookies help us deliver our services. By using our services, you agree to our use of cookies.