$T.REX: Difference between revisions

m
→‎$T.REX: elided duplicated code (from cut-n-paste).
(→‎$T.REX: added/changed comments and whitespace, simplified some code.)
m (→‎$T.REX: elided duplicated code (from cut-n-paste).)
 
(6 intermediate revisions by the same user not shown)
Line 1:
[[Category:REXX library routines]]
 
==$T.REX==
This is the   '''$T.REX'''   (REXX) program which is used by many other REXX programs to display error or informational message(s),
Line 5 ⟶ 7:
::*   highlights (in color) parts (up to 8 unique parts) of the text     (if supported)
::*   write text to a file
::*   breaks/splits the text into multiple lines
::*   adds indentation
::*   justifies the text:   left/right/center/justify   (auto-fill)
::*   add blank lines before and/or after the displaying of text
::*   boxing (around) the text
Line 13 ⟶ 15:
::*   only showing specific lines of the text messages
::*   suppressing specific lines of the text messages
::*   translation of certainspecific characters in the text
::*   allowing other characters to be used for blanks
::*   repeating a text
Line 44 ⟶ 46:
 
The   '''$T'''   REXX program makes use of   '''LINESIZE'''   BIF   which returns the terminals width (linesize).
<br>Some REXXes don't have a &nbsp; '''LINESIZE''' &nbsp; BIF, &nbsp; so one is included here &nbsp; ──► &nbsp; [[LINESIZE.REX]].
 
 
The &nbsp; '''$T''' &nbsp; REXX program makes use of &nbsp; '''SCRSIZE''' &nbsp; BIF which returns the terminals width (linesize) and depth.
<br>Some REXXes don't have a &nbsp; '''SCRSIZE''' &nbsp; BIF, &nbsp; so one is included here &nbsp; ──► &nbsp; [[SCRSIZE.REX]].
 
 
The &nbsp; '''$T''' &nbsp; REXX program makes use of &nbsp; '''DELAY''' &nbsp; BIF which delays (sleeps) for a specified amount of seconds.
<br>Some REXXes don't have a &nbsp; '''DELAY''' &nbsp; BIF, &nbsp; so one is included here &nbsp; ──► &nbsp; [[DELAY.REX]].
 
 
The &nbsp; '''$T''' &nbsp; REXX program makes use of &nbsp; '''SOUND''' &nbsp; BIF which produces sounds via the PC speaker.
<br>Some REXXes don't have a &nbsp; '''SOUND''' &nbsp; BIF, &nbsp; so one is included here &nbsp; ──► &nbsp; [[SOUND.REX]].
 
 
REXX programs not included are &nbsp; '''$H''' &nbsp; which shows '''help''' and other documentation.
<lang rexx>/*REXX program to perform various functions in displaying text to the console (screen). */
 
/* There be many dragons below. */
Line 288 ⟶ 290:
if ?.block\==0 then tLL= 12 + max(LL - 1, 0) * (12 + ?.bs)
else tLL= LL
 
bline= strip(indent || x1 || copies(?.ab, tLL+4*boxing)x2, 'T')
 
if boxing then call ms bx.1 || copies(bx.2, LLx + tLL + 2)bx.3
caLL VEReb ?.e,?.eb
 
 
Line 521 ⟶ 528:
 
do abs(_) while _<99
 
bline= strip(indent || x1 || copies(?.ab, tLL+4*boxing)x2, 'T')
 
if boxing then call ms bx.1 || copies(bx.2, LLx + tLL + 2)bx.3
caLL VEReb ?.e,?.eb
call wit bline
end /*abs*/
Line 937 ⟶ 939:
 
if m | f=='*' then do
_= (word(d H L sw(), 1)) / word(1 2, m + 1)substr(_, 2)
if \datatype(_,"N") then interpret '_=' translate(_,"%",'/')
?.z= _
Line 944 ⟶ 946:
if datatype(_, "N") then ?.z= _ / 1
if \datatype(_, left(t"W", 1) ) then call er 53, _ '.'z"="
if L\=='' then if _<L | _>H then call er 81, L H _ "value for option ."z'='
return _
 
/*──────────────────────────────────────────────────────────────────────────────────────*/
wr: parse arg wr /*write [argument 1] ───> disk. */
if ?.f=='' then return /*Nothing to write? Then skip it.*/
if highL & ahics\=='' then wr= translate(wr, , ahics) /*has highlighting?*/
 
if !cms | !tso then 'EXECIO 1 DISKW' ?.f "(FINIS STRING" wr
Line 960 ⟶ 962:
 
/*══════════════════════════════════════════════════════════════════════════════════════*/
!all: !!=!;!=space(!);upper !;call !fid;!nt=right(!var('OS'),2)=='NT';!cls=word('CLS VMFCLEAR CLRSCREEN',1+!cms+!tso*2);if arg(1)\==1 then return 0;if wordpos(!,'? ?SAMPLES ?AUTHOR ?FLOW')==0 then return 0;!call=']$H';call '$H' !fn !;!call=; return 1
!cal: if symbol('!CALL')\=="VAR" then !call=; return !call
!env: !env='ENVIRONMENT'; if !sys=='"MSDOS'" | !brexx | !r4 | !roo then !env='SYSTEM'; if !os2 then !env='"OS2'"!env; !ebcdic= 3=='f3'x; if !crx then !env='DOS'; return
!fid: parse upper source !sys !fun !fid . 1 . . !fn !ft !fm .; call !sys; if !dos then do; _= lastpos('\', !fn); !fm= left(!fn, _); !fn= substr(!fn, _+1); parse var !fn !fn '.' !ft; end; return word(0 !fn !ft !fm, 1 +('0'arg(1)))
!rex: parse upper version !ver !vernum !verdate .; !brexx= 'BY'==!vernum; !kexx= 'KEXX'==!ver; !pcrexx= 'REXX/PERSONAL'==!ver | 'REXX/PC'==!ver; !r4= 'REXX-R4'==!ver; !regina= 'REXX-REGINA'==left(!ver,11); !roo= 'REXX-ROO'==!ver; call !env; return
!sys: !cms= !sys=='CMS'; !os2= !sys=='"OS2'"; !tso= !sys=='TSO' | !sys=='"MVS'"; !vse= !sys=='VSE'; !dos= pos('"DOS'", !sys)\==0 | pos('WIN', !sys)\==0 | !sys=='"CMD'"; !crx= left(!sys, 6)=='DOSCRX'; call !rex; return
!var: call !fid; if !kexx then return space( dosenv(arg(1) ) ); return space( value(arg(1), , !env) )
$block: !call= '$BLOCK'; call '"$BLOCK'" arg(1); !call=; return result
$mkdir: !call= '$MKDIR'; call '"$MKDIR'" arg(1); !call=; return result
$scale: !call= '$SCALE'; call '"$SCALE'" arg(1); !call=; return result
cp: "EXECIO" '0'arg(2) "CP(STEM CP. STRING" arg(1); return rc
er: parse arg _1,_2; call '$ERR' "14"p(_1) p(word(_1,2) !fid(1)) _2; if _1<0 then return _1; exit result
p: return word( arg(1), 1)
halt: call er .1
kw: parse arg kw; return kw c2x(?.kw)
lower: return translate( arg(1), @abc, @abcu)
noValue: !sigl= sigl; call er 17,!fid(2) !fid(3) !sigl condition('D') sourceline(!sigl)
proper: procedure; arg f 2; parse arg 2 r; return f || r
sd: if ?.scrdepth=='' then parse value scrsize() with ?.scrdepth ?.linesize .; return ?.scrdepth
sw: if ?.linesize=='' then ?.linesize= linesize(); return ?.linesize
syntax: !sigl= sigl; call er 13,!fid(2) !fid(3) !sigl !cal() condition('D') sourceline(!sigl)
wit: call dsay arg(1); call wr arg(1); return</lang>
 
 
[[Category:REXX library routines]]
 
 
Programming note: &nbsp; this REXX program makes use of &nbsp; '''DELAY''' &nbsp; BIF which delays (sleeps) for a specified amount of seconds.
<br>Some REXXes don't have a &nbsp; '''DELAY''' &nbsp; BIF, &nbsp; so one is included here &nbsp; ──► &nbsp; [[DELAY.REX]].