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