{ General utility procedures } { High-density hex } %string(1)%fn hdx1(%integer i) %result = tostring(i + '0') %end %string(2)%fn hdx2(%integer i) %result = "" %if i < 0 { Special } %result = tostring(i >> 4 + '0') . tostring(i & 15 + '0') %end %string(4)%fn hdx4(%integer i) %string(7) s %integer j, k, n s = "" %for n = 1, 1, 4 %cycle j = i // 16 k = i - 16 * j s = tostring(k + '0') . s i = j %repeat %result = s %end %integerfn hdx to i(%string(7) s) %integer i, x = 0 %result = 0 %if s = "" x = x << 4 + charno(s, i) - '0' %c %for i = 1, 1, length(s) %result = x %end { "Normal" hex } %routine pxb(%integer what) %integer ch ch = (what >> 4) & 15 %if 0 <= ch <= 9 %then print symbol(ch + '0') %c %else print symbol(ch - 10 + 'A') ch = what & 15 %if 0 <= ch <= 9 %then print symbol(ch + '0') %c %else print symbol(ch - 10 + 'A') %end { Print time (and perhaps date) } %routine pdate %ownstring(31) current date = "" %string(31) d d = date %if d # current date %start newline printstring("The date is now ") printstring(d) current date = d newline; newline %finish printstring(time) spaces(2) %end { Case conversion } %routine upper(%string(*)%name s) %bytename ch %integer l %return %if s = "" l = length(s) ch == charno(s, 1) %while l > 0 %cycle ch = ch - 'a' + 'A' %if 'a' <= ch <= 'z' ch == ch ++ 1 l = l - 1 %repeat %end { Zap login } %routine zap login(%string(*)%name text) %integer l %return %if text = "" %if charno(text, 1) = 'L' %or charno(text, 1) = 'l' %start l = length(text) l = l - 1 %while l > 0 %and charno(text, l) # ',' length(text) = l %if l # 0 text = text . "????" %finish %end %end %of %file