Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Help with text file reading

21 views
Skip to first unread message

andrewq2

unread,
Apr 9, 2008, 8:30:56 AM4/9/08
to
Cant get dev-pascal to read from a text file contaning a key(key.txt)
code:
uses crt;
label
start;
label
stop;
var
y : byte;
x : byte;
F1 : text;
FN1 : string;
begin
FN1 := 'key.txt';

assign( F1, FN1 );
reset( F1 );

while not EOLN( F1 ) do
begin
readln( F1 );
val(fn1,y);
if y=15712774 then goto start
else;
begin
writeln('Invalid Licence #',y,'');
writeln('now exting');
goto stop;
end;

close( F1 );
start:
repeat
{code}
until x=47;
stop:
end;
end.

Maurice Lombardi

unread,
Apr 9, 2008, 11:54:06 AM4/9/08
to
andrewq2 a écrit :

> Cant get dev-pascal to read from a text file contaning a key(key.txt)

some suggestions below

> code:

> uses crt;
> label
> start;
> label
> stop;
> var
> y : byte;

^ 15712774 is too large for a byte, and even
for a 16 bit integer;
use integer (gpc or delphi: 32 bits) or longint (BP)


> x : byte;
> F1 : text;
> FN1 : string;
> begin
> FN1 := 'key.txt';
>
> assign( F1, FN1 );
> reset( F1 );
>
> while not EOLN( F1 ) do
> begin
> readln( F1 );

( F1, FN1) ???


> val(fn1,y);
> if y=15712774 then goto start
> else;

^ do you really want a ; there.
The following begin end block is _not_ the else clause.
Anyway it makes no change in this case !!!


> begin
> writeln('Invalid Licence #',y,'');
> writeln('now exting');
> goto stop;
> end;
>
> close( F1 );
> start:
> repeat
> {code}
> until x=47;
> stop:
> end;

^ position of this end implies that you can have in F1
several lines with different Licence # and treat all
with a warning if the leadings are not 15712774.
Is that you want ?
> end.


--
Maurice Lombardi
Laboratoire de Spectrometrie Physique,
Universite Joseph Fourier de Grenoble, BP87
38402 Saint Martin d'Heres Cedex FRANCE
Tel: 33 (0)4 76 51 47 51
Fax: 33 (0)4 76 63 54 95
mailto:Maurice....@ujf-grenoble.fr

0 new messages