🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.pascal.borland
Article #645

WHAT COULD BE WRONG?

#645
From: br-pede
Date: Thu, 18 May 2000 00:00
47 lines
2215 bytes

I am trying to make a software, where the user can put in some word, and the
program will look and see if the word(s) is in a wordlist file. Everything
is working pretty well, except this: The procedure is running in a recursive
way, that if you want to look up more than one word, you only put it in next
time you are asked. To exit this, you only have to input an empty string,
that is to press the ENTER key. And here is the trouble. The program will
not stop this looping, unless you enter several empty words.

Here is the snip of the program that is causing trouble:

procedure lookup;
begin
    writeln;
    write('please enter word to be looked up: ');
    readln( s ); { s : STRING; }
    if s = '' then exit; { this doesn't work,
                           unless running a couple of
    assign(f,'wordlist.dat'); reset(f);
    repeat
         read(f,t); { t : STRING }
         if t = s then found := true   else found := false; {found : BOOLEAN}
    until eof(f);
    close(f); {f : FILE OF STRING}
    if not found then begin
         writeln('the word ', s, 'is not found in the list');
         lookup;
      end;{if}
    writeln('the word ', s, ' is found in the list');
end;{ procedure lookup}

Begin
    { call a menu}
    Repeat read(keychoice) until keychoice in [#0 .. #255];
    { keychoice : CHAR }
    if keychoice = '1' then lookup;
    { call the menu}
    ...
end.

Hope anybody out there could help. It will be greatly appriciated.

regards,
Brian
times}
Net-Tamer V 1.11 - Test Drive
Technical Details
Message-ID: <D0OU4.6707$C9.118410@news1.online.no>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1097b9,1d4aea8798c741f5,start
X-Google-Attributes: gid1097b9,public
X-Google-Thread: 111659,1d4aea8798c741f5,start
X-Google-Attributes: gid111659,public
From: br-pede@online.no
Subject: WHAT COULD BE WRONG?
Date: 2000/05/18
Message-ID: <D0OU4.6707$C9.118410@news1.online.no>
X-Deja-AN: 624897372
X-Complaints-To: news-abuse@online.no
X-Trace: news1.online.no 958639267 130.67.18.251 (Thu, 18 May 2000 10:41:07 MET DST)
Organization: Telenor Online Public Access
NNTP-Posting-Date: Thu, 18 May 2000 10:41:07 MET DST
Newsgroups: comp.lang.pascal.borland,dk.edb.programmering.pascal