// RSilUtil.bcpl -- Utilities used throughout SIL system
// bcpl/f RSilUtil.bcpl
get "SysDefs.d"
get "Sil.defs"
let FlushList(link) be
[
until link eq 0 do
[
let tl = link>>item.link
link>>item.link = -1
link = tl
]
]
and IncrementCoords(obj,xinc,yinc) be
[
obj>>item.xmin = obj>>item.xmin+xinc
obj>>item.xmax = obj>>item.xmax+xinc
obj>>item.ymin = obj>>item.ymin+yinc
obj>>item.ymax = obj>>item.ymax+yinc
]
and Length(block) = valof //returns the length of an item
[
//if block>>item.font ne 14 then resultis 6+(block>>item.string.length)/2
//resultis 5
if block>>item.line then resultis 5
resultis 6+(block>>item.string.length)/2
]
// String routines of various sorts
and AppendC(char,string) be
[
let st = string>>str.length +1
string>>str.char↑st = char
string>>str.length = st
]
and AppendS(sts,std) be //copy from source to destination
[
for i = 1 to sts>>str.length do AppendC(sts>>str.char↑i,std)
]
and AppendN(num,str) be //decimal number - no leading spaces
[
let chout = false
let digit = 10000
for i = 4 to 0 by -1 do
[
let ch = (num/digit) + $0
if ch ne $0 % chout % i eq 0 then [ AppendC(ch,str); chout = true ]
num = num rem digit
digit = digit / 10
]
]