unit gen;

interface
Function Strr (N : LongInt) : string;
Function valu(q:string):Integer;
Procedure print(S : String);
procedure printxy(x,y:byte;s:string);
Procedure HideCursor;
Procedure ShowCursor;
var bufstr:byte;
implementation
uses dos,crt;

Procedure HideCursor; Assembler;
Asm
 MOV ax,$0100
 MOV   cx,$2607
 INT   $10
end;

Procedure ShowCursor; Assembler;
Asm
 MOV   ax,$0100
 MOV   cx,$0506
 INT   $10
end;

Function Strr (N : LongInt) : string;
Var Q : string;
Begin
  system.Str (N, Q);
  Strr := Q;
End;

Function valu(q:string):Integer;
Var i,s,pu:Integer;
    r:Real;
Begin
 valu:=0;
 If Length(q)=0 Then exit;
 If Not(q[1] In ['0'..'9','-']) Then exit;
 If Length(q)>5 Then exit;
 Val(q,r,s);
 If s<>0 Then exit;
 If (r<=32767.0) And (r>=-32767.0) Then valu:=Round(r)
End;

Procedure PRINT (S:String);
VAR X,Y:INTEGER;
    R:STRING;
    G:INTEGER;
    bb:integer;
BEGIN
bb:=bufstr;
G:=1;
R:='';
Y:=0;
FOR X:=1 TO LENGTH(S) DO BEGIN
if x=bb then exit;
CASE S[X] OF '|':BEGIN
CASE S[X+1] OF 'B':BEGIN
Y:=VALU(S[X+2]);
CRT.TEXTBACKGROUND(Y);
INC(X,2);
inc(bb,3);
END ELSE BEGIN
R:=S[X+1]+S[X+2];
Y:=VALU(R);
CRT.TEXTCOLOR(Y);
INC(X,2);
inc(bb,3);
END;
END;
END ELSE WRITE(S[X]);
END;
END;
END;

procedure printxy(x,y:byte;s:string);
begin
gotoxy(x,y);
print(S);
end;

begin
end.