Upgrading to GPLv3
[supernova.git] / src / CLUERITE.PAS
1 {//-------------------------------------------------------------------------}\r
2 {/*                                                                         }\r
3 {Copyright (C) 1990, 2009 - Apogee Software, Ltd.                           }\r
4 {                                                                           }\r
5 {This file is part of Supernova.  Supernova is free software; you can       }\r
6 {redistribute it and/or modify it under the terms of the GNU General Public }\r
7 {License as published by the Free Software Foundation; either version 3     }\r
8 {of the License, or (at your option) any later version.                     }\r
9 {                                                                           }\r
10 {This program is distributed in the hope that it will be useful,            }\r
11 {but WITHOUT ANY WARRANTY; without even the implied warranty of             }\r
12 {MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                       }\r
13 {                                                                           }\r
14 {See the GNU General Public License for more details.                       }\r
15 {                                                                           }\r
16 {You should have received a copy of the GNU General Public License          }\r
17 {along with this program; if not, write to the Free Software                }\r
18 {Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.}\r
19 {                                                                           }\r
20 {Original Source: 1990 Scott Miller                                         }\r
21 {Prepared for public release: 03/19/09 - Joe Siegler, Apogee Software, Ltd. }\r
22 {*/                                                                         }\r
23 {//-------------------------------------------------------------------------}\r
24 {$c-}\r
25 const\r
26   Max = 77;\r
27 \r
28 type\r
29   MaxLength = string[Max];\r
30   OneChar   = string[1];\r
31 \r
32 var\r
33   C1                : file of MaxLength;\r
34   Position,Counter,\r
35   Start,Stop,x      : integer;\r
36   Text1             : MaxLength;\r
37   Answer            : char;\r
38   Letter            : OneChar;\r
39   List              : boolean;\r
40 \r
41 procedure Diskwrite(text1: MaxLength; pointer: integer);\r
42   begin\r
43     seek(C1,pointer);\r
44     WRITE(C1,text1);\r
45     writeln('Clue ',pointer,\r
46             ' is written!  Size = ',filesize(C1));\r
47     close(C1);\r
48   end; {End of Diskwrite.}\r
49 \r
50 procedure Diskread(start,stop: integer);\r
51 var\r
52 counter : integer;\r
53 text1   : MaxLength;\r
54   begin\r
55    assign(C1,'C1');\r
56    reset(C1);\r
57    seek(C1,start);\r
58     for counter:= start to stop do\r
59       begin\r
60         highvideo;\r
61         READ(C1,text1);\r
62         if list then writeln(lst,counter,':',text1)\r
63         else\r
64           begin\r
65             writeln('Here is CLUE # ',counter);\r
66             lowvideo;\r
67             writeln(text1);\r
68             highvideo;\r
69           end;\r
70       end;\r
71     close(C1);\r
72     write('The file contains ',filesize(C1),' CLUES.');\r
73   end;  {End of Diskread.}\r
74 \r
75 procedure Beep;\r
76 begin\r
77  if(length(text1)=68)then\r
78   begin sound(99);delay(50);nosound;end;\r
79 end;\r
80 \r
81 BEGIN\r
82 nosound;\r
83 window(2,1,79,25);\r
84 repeat          {Main loop.}\r
85   text1:='';\r
86 \r
87 writeln;\r
88 writeln('Do you want to R)ead, W)rite or Q)uit?');\r
89 read(kbd,answer);\r
90 if upcase(answer) = 'Q' then begin writeln('FINISHED');halt;end;\r
91 if upcase(answer) <> 'R' then       {Write to 'Clues'.}\r
92     begin\r
93       writeln;writeln;\r
94       assign(C1,'C1');\r
95       textcolor(9);writeln('Now RESETing CLUE files.');highvideo;\r
96             RESET(C1);\r
97       writeln;\r
98       writeln('Input a string not more than ',Max,' characters.',\r
99               '  ''\''-Ends string.');\r
100       x:=wherey;if(x>21)then x:=22;for stop:=1 to 3 do writeln;gotoxy(1,x);\r
101       textcolor(11);\r
102         repeat\r
103           read(trm,letter);\r
104           if letter = ^h then\r
105             begin\r
106               write(^h,' ',^h);\r
107               delete(text1,length(text1),2);\r
108             end;\r
109           beep;\r
110           if (letter <> '\') and (letter <> ^h) then text1:=text1+letter\r
111         until (length(text1)=Max) or (letter='\');\r
112         if letter = '\' then\r
113           begin\r
114             writeln;\r
115             highvideo;\r
116             writeln('Total of ',length(text1),' characters.');\r
117           end;\r
118         writeln; highvideo;\r
119         writeln('Total description length = ',length(text1),' characters.');\r
120       writeln('Now WRITING string to disk.');\r
121       writeln('  At what position?  (Next open is # ',filesize(C1),')');\r
122       textcolor(12);position:=position+1;readln(position);highvideo;\r
123       Diskwrite(text1,position);\r
124     end\r
125 else                      {Read from 'Clues'.}\r
126   begin\r
127     writeln;writeln;\r
128     writeln('To the S)creen or the P)rinter');\r
129     read(kbd,answer);\r
130     if(upcase(answer)='P')then List:=True else List:=False;\r
131     assign(C1,'C1');\r
132     reset(C1);\r
133     writeln('Filesize = ',filesize(C1),\r
134             '  (From 0 to ',filesize(C1)-1,')');\r
135     close(C1);\r
136     writeln('Enter starting position:');\r
137     textcolor(12);readln(start);highvideo;\r
138     if(start > filesize(C1)-5)then stop:=(filesize(C1)-1) else\r
139       begin\r
140         writeln('Enter final position:');\r
141         textcolor(12);readln(stop);highvideo;\r
142       end;\r
143     Diskread(start,stop);\r
144   end;  {End of else clause.}\r
145 until false;     {End of Main loop.}\r
146 END.\r
147 \1a\r