home *** CD-ROM | disk | FTP | other *** search
- Program Pattern;
- {Written by Claire A. Rinehart}
- {18C University Houses}
- {Madison, WI 53705}
- { This program is a user supported program}
- {to be distributed under the ShareWare Concept}
- { Last Revision 10-85 }
- Const
- Menu : String[40] = '1Pat, 2Pat, 3Pat, Pal, CT, Quit';
- Type
- String255 = String[255];
- String80 = String[80];
- Var
- Pat : Array[1..3,0..7] of Byte; {array containing the values for the 3 pat}
- Lin : Array[1..3,0..7,0..7] of Char; {the primitive array for pattern input}
- Ind : Integer; {Index of the pattern line}
- Resp : Integer; {choice selected from main menu}
- Pind : Integer; {pattern index 1..3}
- Lind : Integer; {line index}
- Lnum : Integer; {Line number index}
- PalNum : Integer; {Palette number}
- C0,C1,C2,C3 : Integer; {variables for color table}
- Pic : Array[1..8630] of Byte; {used to store the patterns for CT display}
-
- Procedure Convert; {translates - and 0 into the decimal equivalent of the}
- Var {binary pattern for each line}
- Pwr : Integer;
- Sum : Byte;
- Begin
- Sum := 0;
- For Pwr := 0 to 7 do
- begin
- If Lin[Pind, Ind, Pwr] = '0' then Sum := Sum + Round(Exp(Pwr * Ln(2)));
- end;
- Pat[PInd,Ind] := Sum;
- End;
-
- {$I Graph.P }
-
- Procedure Parse(Var Line : String255; Var Word : String80; Delim : Char);
- {Removes first word in Line and returns it in Word. Line is modified so that
- it no longer has leading blanks before the word is filled. The delim constant
- is used to identify the symbol used to delimit words. The Line variable is
- decreased in length by one word, and of course leading blanks, before it is
- returned}
- Const
- Space = ' ';
- Var
- Indx, Len : Integer;
- Begin
- While Pos(Space, Line) = 1 Do {remove leading blanks}
- Delete(Line, 1, 1);
- Len := Pos(Delim, Line);
- If Len = 0 then
- begin {no delimiters left}
- Word := Line;
- Line := '';
- End
- Else If Len = 1 then
- begin {check for two delimiters in a row}
- Word := ''; {return null string}
- Delete(Line, 1, Len); {delete delimiter}
- End
- Else
- Begin {get word and delete from line}
- Word := Copy(Line, 1, Len -1); {get all but delimiter}
- Delete(Line, 1, Len); {delete word plus delimeter}
- End
- End; {of Parse}
-
- Procedure LowToUp(Var Line : string255);
- {Converts characters in Line to upper case}
- Var
- Indx, Len : Integer;
- Begin
- Len := Length(Line);
- For Indx := 1 to Len do
- Line[Indx] := UpCase(Line[Indx]); {built-in TURBO function}
- End; {of LowToUp}
-
- Procedure Answer(Ans : string255; Var Posn : Integer; CaseSen : Boolean);
- {Answer will motitor the keyboard and only allow entry of one of the possible
- matches found in string255. Responses in Ans should be separated by a comma
- and may be padded with blanks, although all leading blanks will be ignored
- when processing a response. When enough keystrokes have been entered to
- identify a match as being unique, the rest of the response is displayed and
- the user can accept the answer by hitting return or can strike the backspace
- key and re-enter another valid response. The procedure returns the ordinal
- position of the response to the calling program for further processing.
- CaseSen is used to determine is the response should be upper/lower case
- sensitive.}
- Label
- Return, Start;
- Var
- Indx : Integer; {number of possible answers}
- ChPos : Integer; {Chacter position index}
- Cnt : Integer; {counter for correct matches}
- Match : Array[1..25] of string80; {possible answer array}
- Mtch : Array[1..25] of Boolean; {Previous match array}
- StrPos : Integer; {index for stepping through matches}
- Ch : Char; {variable read from the keyboard}
- MtchLen : Integer; {contains the length of the match}
- I : Integer; {counter index}
- Begin
- Indx := 0;
- If NOT CaseSen then {Check upper/lower case sensitivity}
- LowToUp(Ans); {If not sensitive then capitalize all ans.}
- While Ans <> '' do {Parse Ans into matching responses}
- Begin
- Indx := Indx + 1; {find number of answers}
- Parse(Ans,Match[Indx],','); {and put them in Match[array]}
- End;
- If Indx = 0 then {Check to see if a string was passed in Ans}
- Begin
- Write('No string was passed to use as a response, please check code.');
- Goto Return;
- End;
- Start:
- For Cnt := 1 to 25 do Mtch[Cnt] := True; {Initialize pointers to all true}
- ChPos := 1;
- Repeat
- Cnt := 0; {set match counter}
- Read(Kbd, Ch); {Get characters from the keyboard}
- If NOT CaseSen then Ch := UpCase(Ch);
- For StrPos := 1 to Indx do {Search all responses for matches}
- Begin
- If Mtch[StrPos] then {Check for previous match}
- If Ch = Copy(Match[StrPos], ChPos, 1) then
- Begin
- Cnt := Cnt + 1; {Count the number of matches}
- Posn := StrPos; {Enter the position of the last}
- End {match in the return variable.}
- End;
- If Cnt = 0 then {Check for no match}
- If Ch = Chr(8) then {Check for a backspace}
- Begin {If backspace has been hit then decrease}
- ChPos := ChPos -1; {the character index by one.}
- If ChPos < 1 then {If the backspace has been over used then}
- Begin {reset to position one and beep.}
- ChPos := 1;
- Write(Chr(7));
- End
- Else
- Begin
- Write(Chr(8));
- Write(Chr(32));
- Write(Chr(8));
- End;
- End
- Else
- Write(Chr(7)) {If the character has no match just beep and}
- Else {don't write it to the screen}
- Begin
- For StrPos := 1 to Indx do
- If Ch <> Copy(Match[StrPos], ChPos, 1) then
- Mtch[StrPos] := False;
- ChPos := ChPos + 1;
- Write(Ch); {Otherwise write the matching character to the}
- End;
- Until Cnt = 1; {screen.}
- MtchLen := Length(Match[Posn]) - ChPos + 1;
- Write(Copy(Match[Posn], ChPos, MtchLen));
- Repeat
- Read(Kbd, Ch);
- If Ch = Chr(8) then
- begin
- For I := 1 to Length(Match[Posn]) do Write(Chr(8));
- For I := 1 to Length(Match[Posn]) do Write(Chr(32));
- For I := 1 to Length(Match[Posn]) do Write(Chr(8));
- ChPos := 1;
- Goto Start;
- end
- else
- If Ord(Ch) <> 13 then Write (Chr(7));
- Until Ord(Ch) = 13;
- Return:
- End; {of Answer}
-
- Procedure Disp;
- Begin
- FillScreen(0);
- Pattern(Pat[1]);
- FillPattern(8, 16, 71, 71, 1);
- FillPattern(248, 16, 311, 71, 1);
- Pattern(Pat[2]);
- FillPattern(88, 16, 151, 71, 2);
- FillPattern(248, 16, 311, 71, 2);
- Pattern(Pat[3]);
- FillPattern(168, 16, 231, 71, 3);
- FillPattern(248, 16, 311, 71, 3);
- End;
-
- Procedure Erase(X, Y, n : Integer);
- Const
- Blank : String[1] = ' ';
- Begin
- GoToXY(X, Y);
- Write(Blank:n); {Writes a blank field n characters long}
- GoToXY(X, Y);
- End;
-
- Begin
- clrscr;
- gotoxy(1,10);
- writeln('Welcome to the PATTERN MAKER');
- writeln;
- writeln(' Writen by Claire A. Rinehart');
- writeln(' (c) 1985');
- writeln;
- Delay (5000);
- GraphColorMode;
- GraphWindow(0, 99, 319, 199);
- GraphBackground(Black);
- Palette(1);
- Window(1, 1, 80, 12);
- FillChar(Pat, SizeOf(Pat), 0);
- Lind := 0;
- GotoXY(1, Lind + 3);
- For Lnum := 7 downto 0 do {set up axis display}
- Writeln(Lnum);
- Write(' 01234567 01234567 01234567');
- Repeat
- GotoXY(1,1);
- Write('CHOOSE: ',Menu); {set up menu}
- Erase(1,2,10);
- Answer(Menu,Resp,False);
- Case Resp of
- 1 : Begin
- PInd := 1;
- Ind := 7;
- For Lind := 0 to 7 do
- Begin
- Erase(1,1,40);
- Write('Enter: P = ',Pind:1,' L = ',Ind:1,' - = Blank, 0 = Dot');
- Erase(2, Lind + 3, 12);
- Read(Lin[Pind,Ind]); {get response line}
- Convert; {convert line to decimal equivalent}
- Write('=',Pat[Pind,Ind]);
- Disp;
- Ind := Ind - 1;
- End;
- End;
- 2 : Begin
- PInd := 2;
- Ind := 7;
- For Lind := 0 to 7 do
- Begin
- Erase(1,1,40);
- Write('Enter: P = ',Pind:1,' L = ',Ind:1,' - = Blank, 0 = Dot');
- Erase(15, Lind + 3, 12);
- Read(Lin[Pind,Ind]);
- Convert;
- Write('=',Pat[Pind,Ind]);
- Disp;
- Ind := Ind - 1;
- End;
- End;
-
- 3 : Begin
- PInd := 3;
- Ind := 7;
- For Lind := 0 to 7 do
- Begin
- Erase(1,1,40);
- Write('Enter: P = ',Pind:1,' L = ',Ind:1,' - = Blank, 0 = Dot');
- Erase(28, Lind + 3, 12);
- Read(Lin[Pind,Ind]);
- Convert;
- Write('=',Pat[Pind,Ind]);
- Disp;
- Ind := Ind - 1;
- End;
- End;
- 4 : Begin {Change Palette}
- Repeat
- Erase(1, 1, 40);
- Write('Enter Palette number: ');
- {$I-}
- Read(PalNum);
- {$I+}
- Until IOresult = 0;
- Palette(PalNum);
- End;
- 5 : Begin {Change Color Table}
- Repeat
- Erase(1, 1, 40);
- Write('Enter values for the Color Table (0-3).');
- Erase(1,2,10);
- {$I-}
- Read(C0, C1, C2, C3);
- {$I+}
- Until IOresult = 0;
- ColorTable(C0, C1, C2, C3);
- GetPic(Pic,8,16,311,71); {getpicture of graphics area and then}
- PutPic(Pic,8,71); {redisplay it so that the color table}
- End; {will be used.}
- End; {Case}
- Until Resp = 6;
- TextMode(C80);
- END.