home *** CD-ROM | disk | FTP | other *** search
- UNIT WEMisc; {$O+}
- { -- This is the Misc. Module of WWIVEdit 2.2.
- -- Last Updated : 8/17/91
- -- Written By: Adam Caldwell
- --
- -- This code is limited Public Domain (see WWIVEDIT.PAS for details
- --
- -- Known Errors : None
- --
- -- Planned Changes : Elimination of this unit.... Put the rest of the
- -- stuff where it belongs
- --
- -- }
- {$R-,V-,S-,B-,E-,N-,F+}{ These Optomize things as much as possible }
-
- INTERFACE
-
- USES WEVars, WEString, WELine, WETime, WEKbd, WEOutput, WEInput;
-
-
- PROCEDURE input(VAR i:string; { Allows user to input a string of }
- maxlength:integer); { MaxLength Characters }
- PROCEDURE InputUp(VAR i:string; { Allows user to input a string of }
- maxlength:integer); { MaxLength then converts it to uppercase }
- FUNCTION CheckAbort:boolean; { Returns True if SPACE is pressed, will }
- { pause if P or Ctrl-S is pressed }
-
- PROCEDURE EnableInts; INLINE($FB);
- PROCEDURE DisableInts; INLINE($FA);
- PROCEDURE SaveInfo;
- PROCEDURE DoJump;
- FUNCTION Search(VAR cx,cy:integer; S,Ops:string):boolean;
- PROCEDURE SearchLast;
- PROCEDURE DoSearch;
-
- IMPLEMENTATION
-
-
- USES Dos;
-
- FUNCTION CheckAbort:Boolean;
- VAR
- cc:char;
- BEGIN
- IF KeyPressed THEN
- BEGIN
- cc:=upcase(ReadKey);
- IF (cc = 'P') OR (cc = ^S) THEN
- BEGIN
- cc := readkey;
- cc := #0;
- END;
- CheckAbort:=(CC=' ');
- END
- ELSE CheckAbort:=FALSE;
- END;
-
-
-
-
- PROCEDURE input1(VAR s : string; ml : integer; ToUp : boolean);
- VAR
- ch : char;
-
- BEGIN
- s:='';
- REPEAT
- ch := GetKey;
- IF ToUp THEN
- ch := upcase(ch);
- IF (ch IN [#32..#255]-[#127]) AND (length(s)<=ml) THEN
- BEGIN
- s:=s+ch;
- prompt(ch);
- END
- ELSE
- CASE ch OF
- #8,#127 : IF Length(s)>0 THEN
- BEGIN
- prompt(#8#32#8);
- delete(s,length(s),1);
- END;
- ^X, ^U : WHILE s<>'' DO
- BEGIN
- prompt(#8#32#8);
- delete(s,length(s),1);
- END;
- END;
- UNTIL (ch = #13);
- nl;
- END;
-
- PROCEDURE input(VAR i : string; maxlength : integer);
- BEGIN
- input1(i,maxlength,false);
- END;
-
-
- PROCEDURE inputup(VAR i : string; maxlength : integer);
- BEGIN
- input1(i,maxlength,true);
- END;
-
-
-
- PROCEDURE SaveInfo;
- BEGIN
- reset(InfoFile);
- seek(InfoFile,usernum);
- write(InfoFile,Info);
- close(InfoFile);
- END;
-
-
-
- PROCEDURE DoJump;
- { Prompts for a line to jump to, and then changes cursor position accordingly }
- VAR
- s:string;
- line:integer;
- BEGIN
- StatusLine3(C2+'Jump to which line? > '+c4+' '+#8#8#8#8);
- Input(s,4);
- line:=value(s);
- IF (line>0) AND (line<MaxLines) THEN
- BEGIN
- cy:=line;
- cx:=1;
- ViewTop:=cy;
- ViewBottom:=cy+WindowHeight;
- IF ViewBottom>MaxLines THEN BEGIN
- ViewBottom:=MaxLines;
- ViewTop:=ViewBottom-WindowHeight
- END;
- END;
- ansic('0');
- StatusLine3('');
- END;
-
- FUNCTION Search(VAR cx,cy:integer; S,Ops:string):boolean;
- { performs a search from the given coordinates }
- VAR
- i:integer;
- found:boolean;
- l:string;
- BEGIN
- IF pos('U',ops)>0 THEN S:=TransformString(S);
- Found:=false;
- i:=cy;
- WHILE NOT Found AND (i<MaxLines) Do
- BEGIN
- IF pos('U',ops)>0
- THEN l:=TransformString(Line[i]^.l)
- ELSE l:=Line[i]^.l;
- IF ((cx<pos(s,l)) AND (cy=i)) OR ((pos(s,l)<>0) AND (cy<>i)) THEN
- BEGIN
- cx:=pos(s,l);
- cy:=i;
- Found:=true;
- END
- ELSE inc(i);
- END;
- Search:=Found;
- END;
-
- PROCEDURE SearchLast;
- { Repeats last Search }
- BEGIN
- IF NOT Search(cx,cy,SearchString,SearchOps) THEN BEGIN
- StatusLine3('No match found');
- AfterNext:=ClrStatLine3;
- END;
- END;
-
-
- PROCEDURE DoSearch;
- { Prompts for something to search for, and then does the search }
- VAR
- x:integer;
- BEGIN
- StatusLine3(C2+'Search for > '+C4+dup(' ',60)+ESC+'[60D');
- input(SearchString,60);
- Ansic('0');
- { StatusLine3(C2+'Options > '+C4+' '+#8#8#8#8#8);
- InputUp(SearchOps,5); }
- SearchOps:='U';
- ansic('0');
- StatusLine3('');
- IF NOT Search(cx,cy,SearchString,SearchOps) THEN BEGIN
- StatusLine3('No match found');
- AfterNext:=ClrStatLine3;
- END;
- END;
-
-
-
-
-
- END.
-
-