home *** CD-ROM | disk | FTP | other *** search
- Unit sTypes;
-
- Interface
-
- Uses Graph;
-
- Type
- PChar=^Char;
-
- Function StrDispose(sP:PChar):Byte;
- Procedure StrSet(P:PChar;S:String);
- Procedure StrPas(var S:String;P:PChar);
- Procedure CenterText(X1,Y1,X2,Y2:Word;Title:PChar);
- Function StrNew(S:String):Pointer;
-
- Implementation
-
- Function StrNew(S:String):Pointer;
- Type
- A=Array[0..255] Of Char;
- Pnt=^A;
- Var
- P:Pnt;
-
- Begin
- New(P);
- StrSet(PChar(P),S);
- StrNew:=P;
- End;
-
- Function StrDispose(sP:PChar):Byte;
- Type
- A=Array[0..255] Of Char;
- Pnt=^A;
- Var
- P:Pnt;
- Begin
- P:=Pnt(sP);
- Dispose(P);
- StrDispose:=1;
- End;
-
- Procedure CenterText(X1,Y1,X2,Y2:Word;Title:PChar);
- Var
- Center:Word;
- TitleString:String;
-
- Begin
- SetViewPort(X1,Y1,X2,Y2,ClipOn);
- Center:=(X2-X1) div 2;
- StrPas(TitleString,Title);
- OutTextXY(Center-TextWidth(TitleString)div 2,3,TitleString);
- SetViewPort(0,0,GetMaxX,GetMaxY,ClipOn);
- End;
-
- Procedure StrPas(var S:String;P:PChar);
- Var
- t:Byte;
- x,y:Word;
-
- Begin
- t:=1;
- While P^<>#0 Do
- Begin
- S[t]:=P^;
- x:=Ofs(P^);
- y:=Seg(P^);
- Inc(x);
- P:=Ptr(y,x);
- inc(t);
- End;
- S[0]:=Chr(t-1);
- End;
-
- Procedure StrSet(P:PChar;S:String);
- Var
- t:Byte;
- x,y:Word;
-
- Begin
- For t:=1 to Length(S) Do
- Begin
- P^:=S[t];
- x:=Ofs(P^);
- y:=Seg(P^);
- Inc(x);
- P:=Ptr(y,x);
- End;
- P^:=#0;
- End;
-
- End.