Module io2 = Begin Require 'bliss.req'; External Routine DelName, OutSym : Novalue, Out11Str : Novalue, OutCrlf : Novalue, Output : Novalue; Own save; ! ! io.bli - routines for writing to the files ! Macro va_arg(i) = (i = .i + 1; ActualParameter(.i)) %; ! ! Convert(s,n,r) - convert a number to a string ! Routine Convert(s : Ref Vector[,Byte],n,r) = Begin Local f; Bind hex = Uplit('0123456789abcdef') : Vector[,Byte]; f = 0; If .r Lss 0 Then Begin r = -.r; If .n Lss 0 Then Begin n = -.n; f = 1; End End; s = .s + 31; s[0] = 0; Do Begin s = .s - 1; s[0] = .hex[.n Mod .r]; n = .n / .r End While .n Gtr 0; If .f Then Begin s = .s - 1; s[0] = '-' End; Return .s End; ! ! Print(msg,...) - display a formatted message ! Global Routine Print(ctl : Ref Vector[,Byte]) = Begin Builtin actualparameter; Local c,i,k,len, jst,padding,sts, s : Ref Vector[,Byte], temp : Vector[32,Byte]; Label aaa; sts = 0; i = 1; While (c = ch$rchar_a(ctl)) Neq 0 Do If .c Eql '\' Then Begin c = ch$rchar_a(ctl); If .c Eql 't' Then Output(9) Else If .c Eql 'n' Then OutCrlf() Else If .c Eql 'f' Then Output(12) Else Output(.c) End Else If .c Neq '%' Then Output(.c) Else aaa: Begin len = 0; jst = 0; padding = ' '; c = ch$rchar_a(ctl); If .c Eql '-' Then Begin jst = 1; c = ch$rchar_a(ctl) End; If .c Eql '0' Then Begin padding = '0'; c = ch$rchar_a(ctl) End; If .c Eql '*' Then Begin len = va_arg(i); c = ch$rchar_a(ctl) End Else While .c Geq '0' And .c Leq '9' Do Begin len = .len * 10 + .c - '0'; c = ch$rchar_a(ctl) End; s = temp; Case .c From 'b' To 'x' Of Set [Inrange,Outrange]: Begin s[0] = .c; s[1] = 0 End; ['b']: Begin save = .device; Leave aaa End; ['c']: Begin s[0] = va_arg(i); s[1] = 0 End; ['d']: s = Convert(temp,va_arg(i),-10); ['e']: Begin device = .save; Leave aaa End; ['l']: s = DelName(va_arg(i)); ['m']: Begin device = .len; If .flg_tty Or Not .swit_list Then device<1,1> = 0; Leave aaa End; ['p']: Begin OutSym(va_arg(i)); Leave aaa End; ['o']: s = Convert(temp,va_arg(i),8); ['r']: Begin sts = 1; Leave aaa End; ['s']: s = va_arg(i); ['t']: Begin s[0] = 0; c = va_arg(i) End; ['u']: s = Convert(temp,va_arg(i),10); ['w']: Begin Out11Str(va_arg(i)); Leave aaa End; ['x']: s = Convert(temp,va_arg(i),16) Tes; k = ch$find_ch(256,.s,0) - .s; If Not .jst Then While .len Gtr .k Do Begin Output(.padding); len = .len - 1 End; While (c = ch$rchar_a(s)) Neq 0 Do Output(.c); If .jst Then While .len Gtr .k Do Begin Output(.padding); len = .len - 1 End End; Return .sts End; End Eludom