Updating FSF address and adding website URL
[supernova.git] / src / SPECIAL.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, see https://gnu.org/licenses or write to: }\r
18 {  Free Software Foundation, Inc.                                           }\r
19 {  51 Franklin Street, Fifth Floor                                          }\r
20 {  Boston, MA 02110-1301                                                    }\r
21 {  USA                                                                      }\r
22 {                                                                           }\r
23 {Original Source: 1990 Scott Miller                                         }\r
24 {Prepared for public release: 03/19/09 - Joe Siegler, Apogee Software, Ltd. }\r
25 {*/                                                                         }\r
26 {//-------------------------------------------------------------------------}\r
27 {$c-}\r
28 const\r
29   Max = 234;\r
30 \r
31 type\r
32   MaxLength = string[Max];\r
33   OneChar   = string[1];\r
34 \r
35 var\r
36   S1                : file of MaxLength;\r
37   Position,Counter,\r
38   Start,Stop,x      : integer;\r
39   Text1             : MaxLength;\r
40   Answer            : char;\r
41   Letter            : OneChar;\r
42   List              : boolean;\r
43 \r
44 procedure Diskwrite(text1: MaxLength; pointer: integer);\r
45   begin\r
46     seek(S1,pointer);\r
47     WRITE(S1,text1);\r
48     writeln('SPECIAL decription ',pointer,\r
49             ' is written!  Size = ',filesize(S1));\r
50     close(S1);\r
51   end; {End of Diskwrite.}\r
52 \r
53 procedure Diskread(start,stop: integer);\r
54 var\r
55 counter : integer;\r
56 text1   : MaxLength;\r
57   begin\r
58    assign(S1,'S1');\r
59    reset(S1);\r
60    seek(S1,start);\r
61     for counter:= start to stop do\r
62       begin\r
63         highvideo;\r
64         READ(S1,text1);\r
65         if list then\r
66           begin\r
67             writeln(lst,'Discription # ',counter);\r
68             writeln(lst,text1);\r
69           end\r
70         else\r
71           begin\r
72             writeln('Here is SPECIAL description # ',counter);\r
73             lowvideo;\r
74             writeln(text1);\r
75             highvideo;\r
76           end;\r
77       end;\r
78     close(S1);\r
79     write('The file contains ',filesize(S1),' SPECIAL descriptions.');\r
80   end;  {End of Diskread.}\r
81 \r
82 procedure Beep;\r
83 begin\r
84  if(length(text1)in[68,146,224])then\r
85   begin sound(99);delay(50);nosound;end;\r
86 end;\r
87 \r
88 BEGIN\r
89 nosound;\r
90 window(2,1,79,25);\r
91 repeat          {Main loop.}\r
92   text1:='';\r
93 \r
94 writeln;\r
95 writeln('Do you want to R)ead, W)rite or Q)uit?');\r
96 read(kbd,answer);\r
97 if upcase(answer) = 'Q' then begin writeln('FINISHED');halt;end;\r
98 if upcase(answer) <> 'R' then       {Write to 'SPECIAL'.}\r
99     begin\r
100       writeln;writeln;\r
101       assign(S1,'S1');\r
102       textcolor(9);writeln('Now RESETing SPECIAL files.');highvideo;\r
103             RESET(S1);\r
104       writeln;\r
105       writeln('Input a string not more than ',Max,' characters.',\r
106               '  ''\''-Ends string.');\r
107       x:=wherey;if(x>17)then x:=18;for stop:=1 to 7 do writeln;gotoxy(1,x);\r
108       textcolor(11);\r
109         repeat\r
110           read(trm,letter);\r
111           if letter = ^h then\r
112             begin\r
113               if(wherex=1)then\r
114                begin window(2,1,80,25);gotoxy(79,wherey-1)end;\r
115               write(^h,' ',^h);\r
116               delete(text1,length(text1),2);\r
117               window(2,1,79,25);\r
118             end;\r
119           beep;\r
120           if (letter <> '\') and (letter <> ^h) then text1:=text1+letter\r
121         until (length(text1)=Max) or (letter='\');\r
122         if letter = '\' then\r
123           begin\r
124             writeln;\r
125             highvideo;\r
126             writeln('Total of ',length(text1),' characters.');\r
127           end;\r
128         writeln; highvideo;\r
129         writeln('Total description length = ',length(text1),' characters.');\r
130       writeln('Now WRITING string to disk.');\r
131       writeln('  At what position?  (Next open is # ',filesize(S1),')');\r
132       textcolor(12);position:=position+1;readln(position);highvideo;\r
133       Diskwrite(text1,position);\r
134     end\r
135 else                      {Read from 'SPECIAL'.}\r
136   begin\r
137     writeln;writeln;\r
138     writeln('To the S)creen or the P)rinter');\r
139     read(kbd,answer);\r
140     if(upcase(answer)='P')then List:=True else List:=False;\r
141     assign(S1,'S1');\r
142     reset(S1);\r
143     writeln('Filesize = ',filesize(S1),\r
144             '  (From 0 to ',filesize(S1)-1,')');\r
145     close(S1);\r
146     writeln('Enter starting position:');\r
147     textcolor(12);readln(start);highvideo;\r
148     if(start > filesize(S1)-5)then stop:=(filesize(S1)-1) else\r
149       begin\r
150         writeln('Enter final position:');\r
151         textcolor(12);readln(stop);highvideo;\r
152       end;\r
153     Diskread(start,stop);\r
154   end;  {End of else clause.}\r
155 until false;     {End of Main loop.}\r
156 END.\r
157 \r
158 \r
159 \1a\r