Anonymous user
$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
::* 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 '''LINESIZE''' BIF, so one is included here ──► [[LINESIZE.REX]].
The '''$T''' REXX program makes use of '''SCRSIZE''' BIF which returns the terminals width (linesize) and depth.
<br>Some REXXes don't have a '''SCRSIZE''' BIF, so one is included here ──► [[SCRSIZE.REX]].
The '''$T''' REXX program makes use of '''DELAY''' BIF which delays (sleeps) for a specified amount of seconds.
<br>Some REXXes don't have a '''DELAY''' BIF, so one is included here ──► [[DELAY.REX]].
The '''$T''' REXX program makes use of '''SOUND''' BIF which produces sounds via the PC speaker.
<br>Some REXXes don't have a '''SOUND''' BIF, so one is included here ──► [[SOUND.REX]].
REXX programs not included are '''$H''' which shows '''help''' and other documentation.
<lang rexx>
/* 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
return _
/*──────────────────────────────────────────────────────────────────────────────────────*/
wr: parse
if ?.f=='' then return /*Nothing to write? Then skip it.*/
if highL & ahics\=='' then wr= translate(wr, , ahics)
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==
!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==
!var: call !fid; if !kexx then return space( dosenv(arg(1) ) ); return space( value(arg(1), , !env) )
$block: !call= '$BLOCK'; call
$mkdir: !call= '$MKDIR'; call
$scale: !call= '$SCALE'; call
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: this REXX program makes use of '''DELAY''' BIF which delays (sleeps) for a specified amount of seconds.
<br>Some REXXes don't have a '''DELAY''' BIF, so one is included here ──► [[DELAY.REX]].
|