Board index » delphi » Hey, people! I'm a Good Citizen, so Why not Answer my Question???

Hey, people! I'm a Good Citizen, so Why not Answer my Question???

I have asked this question twice with no acceptable answer. Please
help!

The following code worked for me for YEARS, but now fails when I run
the program with the internal de{*word*81} on (Pentium Pro 200):

assign(fn,'non_existent_file');
{$i-}reset(fn);{$i+}
if ioresult = 0 then begin
        do stuff when file exists....
end;

the program ALWAYS tell me the file exists, and opens it for input
from the keyboard if it does not exist. This is indeed a shocker! I
have rewritten important code using filefirst to get around this, but
I'm lost as to what's happening (I even reinstalled the compiler, to
no avail). BTW, this only occurs when I am in the IDE. BP works
normally with the standalone de{*word*81} or when the program is run from
the command line. It also works correctly from native MSDOS mode--just
not in a DOS box.

The problem is not in another part of the program, since I can run a
stand-alone with the above code, and the same thing happens.

I am even willing to pay Borland to help me with this. Does anyone
know the number to call.

I wish Borland would sell their XXX???!!! Pascal compiler to someone
who will support it and develop it....

Thanks

Herbert Gintis
Department of Economics           Phone: 413-586-7756
University of Massachusetts       Fax:   413-586-6014
Amherst, MA 01003
gin...@econs.umass.edu            http://www-unix.oit.umass.edu/~gintis/

 

Re:Hey, people! I'm a Good Citizen, so Why not Answer my Question???


Umm is there a question in here?

                                        -The Sequence

Herbert M. Gintis <gin...@econs.umass.edu> wrote in article
<32a78658.13682...@news.oit.umass.edu>...

Quote
> I have asked this question twice with no acceptable answer. Please
> help!

> The following code worked for me for YEARS, but now fails when I run
> the program with the internal de{*word*81} on (Pentium Pro 200):

> assign(fn,'non_existent_file');
> {$i-}reset(fn);{$i+}
> if ioresult = 0 then begin
>    do stuff when file exists....
> end;

> the program ALWAYS tell me the file exists, and opens it for input
> from the keyboard if it does not exist. This is indeed a shocker! I
> have rewritten important code using filefirst to get around this, but
> I'm lost as to what's happening (I even reinstalled the compiler, to
> no avail). BTW, this only occurs when I am in the IDE. BP works
> normally with the standalone de{*word*81} or when the program is run from
> the command line. It also works correctly from native MSDOS mode--just
> not in a DOS box.

> The problem is not in another part of the program, since I can run a
> stand-alone with the above code, and the same thing happens.

> I am even willing to pay Borland to help me with this. Does anyone
> know the number to call.

> I wish Borland would sell their XXX???!!! Pascal compiler to someone
> who will support it and develop it....

> Thanks

> Herbert Gintis
> Department of Economics           Phone: 413-586-7756
> University of Massachusetts       Fax:   413-586-6014
> Amherst, MA 01003
> gin...@econs.umass.edu            http://www-unix.oit.umass.edu/~gintis/

Re:Hey, people! I'm a Good Citizen, so Why not Answer my Question???


Quote
>assign(fn,'non_existent_file');
>{$i-}reset(fn);{$i+}
>if ioresult = 0 then begin
>        do stuff when file exists....
>end;

i dont know what is wrong with that, but here's what i use:

function fileexists(fname:string):boolean;
var s : string;
begin
  s := fsearch(fname,'');
  fileexists := s <> 0;
end;

example: check to see if file filename.dat exists. (pretend it doesn't)

if fileexists('filename.dat') = false then...

hope this helps

Re:Hey, people! I'm a Good Citizen, so Why not Answer my Question???


On 6 Dec 1996 04:13:08 GMT, "The Sequence" <sequ...@ix.netcom.com>
wrote:

Quote
>Umm is there a question in here?

>                                    -The Sequence

        The question is: why won't this run properly under the IDE in a DOS
box running under windows 95,, but does what it is supposed to do with
the stand-alone de{*word*81} and when run from the command line, or from
msdos 7.0 alone, without windows.

Herb Gintis

        It's not a memory problem since I've change the memory.

Quote
>Herbert M. Gintis <gin...@econs.umass.edu> wrote in article
><32a78658.13682...@news.oit.umass.edu>...
>> I have asked this question twice with no acceptable answer. Please
>> help!

>> The following code worked for me for YEARS, but now fails when I run
>> the program with the internal de{*word*81} on (Pentium Pro 200):

>> assign(fn,'non_existent_file');
>> {$i-}reset(fn);{$i+}
>> if ioresult = 0 then begin
>>        do stuff when file exists....
>> end;

>> the program ALWAYS tell me the file exists, and opens it for input
>> from the keyboard if it does not exist. This is indeed a shocker! I
>> have rewritten important code using filefirst to get around this, but
>> I'm lost as to what's happening (I even reinstalled the compiler, to
>> no avail). BTW, this only occurs when I am in the IDE. BP works
>> normally with the standalone de{*word*81} or when the program is run from
>> the command line. It also works correctly from native MSDOS mode--just
>> not in a DOS box.

>> The problem is not in another part of the program, since I can run a
>> stand-alone with the above code, and the same thing happens.

>> I am even willing to pay Borland to help me with this. Does anyone
>> know the number to call.

>> I wish Borland would sell their XXX???!!! Pascal compiler to someone
>> who will support it and develop it....

>> Thanks

>> Herbert Gintis
>> Department of Economics           Phone: 413-586-7756
>> University of Massachusetts       Fax:   413-586-6014
>> Amherst, MA 01003
>> gin...@econs.umass.edu            http://www-unix.oit.umass.edu/~gintis/

Herbert Gintis
Department of Economics           Phone: 413-586-7756
University of Massachusetts       Fax:   413-586-6014
Amherst, MA 01003
gin...@econs.umass.edu            http://www-unix.oit.umass.edu/~gintis/

Re:Hey, people! I'm a Good Citizen, so Why not Answer my Question???


On 7 Dec 1996 08:02:54 GMT, <darqs...@tima.com> (DarqSide) wrote:
Yes, that's an alternative, and I have replaced my code with something
like yours (I'll try yours as well--I'm sure it will work). I'm just
afraid of the hundreds of places I've used the old code, which now
doesn't work!

Thanks,

Herb Gintis

Quote
>i dont know what is wrong with that, but here's what i use:

>function fileexists(fname:string):boolean;
>var s : string;
>begin
>  s := fsearch(fname,'');
>  fileexists := s <> 0;
>end;

>example: check to see if file filename.dat exists. (pretend it doesn't)

>if fileexists('filename.dat') = false then...

>hope this helps

Herbert Gintis
Department of Economics           Phone: 413-586-7756
University of Massachusetts       Fax:   413-586-6014
Amherst, MA 01003
gin...@econs.umass.edu            http://www-unix.oit.umass.edu/~gintis/

Re:Hey, people! I'm a Good Citizen, so Why not Answer my Question???


On 7 Dec 1996 08:02:54 GMT,  <darqs...@tima.com> (DarqSide) wrote:

Quote
>i dont know what is wrong with that, but here's what i use:

>function fileexists(fname:string):boolean;
>var s : string;
>begin
>  s := fsearch(fname,'');
>  fileexists := s <> 0;
>end;

I believe you mean s <> '', or Length(s) <> 0.  Don't worry, sometimes
happens when we try to take something off the top of our heads.  :-)

    ...red

Re:Hey, people! I'm a Good Citizen, so Why not Answer my Question???


Quote
> Yes, that's an alternative, and I have replaced my code with something
> like yours (I'll try yours as well--I'm sure it will work). I'm just
> afraid of the hundreds of places I've used the old code, which now
> doesn't work!

   Ahhhh - a ringing endor{*word*224}t for modularity and TP/BP Units, I'd
say!  If you had designed your applications with this common function in
one place, callable from anywhere, you'd have not problem, would you?
   Sorry to embarrass you, but this should be a good object lesson for
younger "students" here, I feel...

Re:Hey, people! I'm a Good Citizen, so Why not Answer my Question???


In article <01bbe32b$9798e820$a4d823c7@default>, The Sequence
<sequ...@ix.netcom.com> writes

Quote
>Umm is there a question in here?

>                                       -The Sequence

>Herbert M. Gintis <gin...@econs.umass.edu> wrote in article
><32a78658.13682...@news.oit.umass.edu>...
>> I have asked this question twice with no acceptable answer. Please
>> help!

>> The following code worked for me for YEARS, but now fails when I run
>> the program with the internal de{*word*81} on (Pentium Pro 200):

>> assign(fn,'non_existent_file');
>> {$i-}reset(fn);{$i+}
>> if ioresult = 0 then begin
>>      do stuff when file exists....
>> end;

>> the program ALWAYS tell me the file exists,

If the problem is the recognition of a file (because your using a
pentium) try this.  Possibly assign is creating the file.  I am a
beginner to pascal so please don't flame me for trying to help.  This
was given to me by a friend and hasn't failed yet.

function Exist(Name: String) : boolean;
var   F : Dos.SearchRec;
begin
{$I-}
   FindFirst(Name,Dos.AnyFile,F);
{$I+}
Exist:=(DosError=0);
DosError:=IoResult;
DosError:=IoResult;
end; {exist}
--
: Andrew Mawdsley                \  No email adverts please
: A...@apmawds.demon.co.uk         \       Reply won't work
  Electronic design engineer         \       Pride prevents
  PAC International LTD.    England    \      learning from
  Andr...@pac-intl.mhs.compuserve.com    \        mistakes.
  My views are not those of my employers   \  .............
  Visit Proximity Access Control at    hhtp://www.pac.co.uk

Re:Hey, people! I'm a Good Citizen, so Why not Answer my Question???


Quote
In article <32a976ce.4227...@news.gnn.com> RDon...@gnn.com "R.E.Donais" writes:
> I believe you mean s <> '', or Length(s) <> 0.  Don't worry, sometimes
> happens when we try to take something off the top of our heads.  :-)

Another nice function to see if a file exists:

Function FileExists(FileName: string): Boolean;
Var
  F     : File;
Begin
  Assign(F,FileName);
  {$i-}
  Reset(F);
  Close(F);
  {$i+}
  FileExists :=(IOResult=0);
End;

Works for me =]

--
[+]>>-- - .oO Bernhard van Staveren Oo. - --<<[+]
|                                               |
| Mail: mad...@xirian.demon.nl                  |
|       mad...@pitel-lnx.ibk.fnt.hvu.nl         |
| Http: http://pitel-lnx.ibk.fnt.hvu.nl/~madcat |
|                                               |
[+]>>-- - .oO  Xirian  Consultancy  Oo. - --<<[+]

Re:Hey, people! I'm a Good Citizen, so Why not Answer my Question???


Well, I'm a big fan of modularity, but not for three lines of code!

Herb

On 7 Dec 1996 11:12:03 -0700, Mike Copeland <mrc...@primenet.com>
wrote:

Quote
>> Yes, that's an alternative, and I have replaced my code with something
>> like yours (I'll try yours as well--I'm sure it will work). I'm just
>> afraid of the hundreds of places I've used the old code, which now
>> doesn't work!

>   Ahhhh - a ringing endor{*word*224}t for modularity and TP/BP Units, I'd
>say!  If you had designed your applications with this common function in
>one place, callable from anywhere, you'd have not problem, would you?
>   Sorry to embarrass you, but this should be a good object lesson for
>younger "students" here, I feel...

Herbert Gintis
Department of Economics           Phone: 413-586-7756
University of Massachusetts       Fax:   413-586-6014
Amherst, MA 01003
gin...@econs.umass.edu            http://www-unix.oit.umass.edu/~gintis/

Re:Hey, people! I'm a Good Citizen, so Why not Answer my Question???


Hmmmm, seems like a good trade-off to me: 200 one-line calls to a
routine which has 3 code lines - which can be changed in _one_place_ -
versus changing 200 lines of code scattered throughout the program and
which has the potential of incurring at least a _few_ coding errors.
   Making a 3-line common function a subprogram may seem silly, but when
you code it 200 times (600 lines of actual code) - and you have to
CHANGE it! - don't you really wish you had made it a subprogram?  Gee,
it was more than 35 years ago when I learned how painful such an effort
can be, and that's when I started making _any_ code I found myself
repeating into a subprogram... 8<}}

Quote
> Well, I'm a big fan of modularity, but not for three lines of code!

> >> Yes, that's an alternative, and I have replaced my code with something
> >> like yours (I'll try yours as well--I'm sure it will work). I'm just
> >> afraid of the hundreds of places I've used the old code, which now
> >> doesn't work!

> >   Ahhhh - a ringing endor{*word*224}t for modularity and TP/BP Units, I'd
> >say!  If you had designed your applications with this common function in
> >one place, callable from anywhere, you'd have not problem, would you?
> >   Sorry to embarrass you, but this should be a good object lesson for
> >younger "students" here, I feel...

Re:Hey, people! I'm a Good Citizen, so Why not Answer my Question???


Your source works fine for me.

Program Hi;
var
  fn :text;
Begin
  assign(fn,'non_existent_file');
  {$i-}reset(fn);{$i+}
  if ioresult = 0 then
    begin
      Write(fn,'Hi');
      (* do stuff when file exists.... *)
    end;
end.

Andi <a...@see.sig.at.end> wrote in article
<ZHFmNvASdbqyE...@apmawds.demon.co.uk>...

Quote
> In article <01bbe32b$9798e820$a4d823c7@default>, The Sequence
> <sequ...@ix.netcom.com> writes
> >Umm is there a question in here?

> >                                       -The Sequence

> >Herbert M. Gintis <gin...@econs.umass.edu> wrote in article
> ><32a78658.13682...@news.oit.umass.edu>...
> >> I have asked this question twice with no acceptable answer. Please
> >> help!

> >> The following code worked for me for YEARS, but now fails when I run
> >> the program with the internal de{*word*81} on (Pentium Pro 200):

> >> assign(fn,'non_existent_file');
> >> {$i-}reset(fn);{$i+}
> >> if ioresult = 0 then begin
> >>      do stuff when file exists....
> >> end;

> >> the program ALWAYS tell me the file exists,

> If the problem is the recognition of a file (because your using a
> pentium) try this.  Possibly assign is creating the file.  I am a
> beginner to pascal so please don't flame me for trying to help.  This
> was given to me by a friend and hasn't failed yet.

> function Exist(Name: String) : boolean;
> var   F : Dos.SearchRec;
> begin
> {$I-}
>    FindFirst(Name,Dos.AnyFile,F);
> {$I+}
> Exist:=(DosError=0);
> DosError:=IoResult;
> DosError:=IoResult;
> end; {exist}
> --
> : Andrew Mawdsley                \  No email adverts please
> : A...@apmawds.demon.co.uk         \       Reply won't work
>   Electronic design engineer         \       Pride prevents
>   PAC International LTD.    England    \      learning from
>   Andr...@pac-intl.mhs.compuserve.com    \        mistakes.
>   My views are not those of my employers   \  .............
>   Visit Proximity Access Control at    hhtp://www.pac.co.uk

Re:Hey, people! I'm a Good Citizen, so Why not Answer my Question???


In article <32a78658.13682...@news.oit.umass.edu> of Fri, 6 Dec 1996
02:37:28 in comp.lang.pascal.borland, "Herbert M. Gintis"

Quote
<gin...@econs.umass.edu> wrote:
>I have asked this question twice with no acceptable answer. Please
>help!

>The following code worked for me for YEARS, but now fails when I run
>the program with the internal de{*word*81} on (Pentium Pro 200):

>assign(fn,'non_existent_file');
>{$i-}reset(fn);{$i+}
>if ioresult = 0 then begin
>       do stuff when file exists....
>end;

>the program ALWAYS tell me the file exists, and opens it for input
>from the keyboard if it does not exist. This is indeed a shocker! I
>have rewritten important code using filefirst to get around this, but
>I'm lost as to what's happening (I even reinstalled the compiler, to
>no avail). BTW, this only occurs when I am in the IDE. BP works
>normally with the standalone de{*word*81} or when the program is run from
>the command line. It also works correctly from native MSDOS mode--just
>not in a DOS box.

I'm not clear exactly what your software setup is - Win95? BP7.00 or
BP7.01? The code can hardly have been like that for years, because it has
a strange file name by BP7 standards.  What with proper 8.3 names?

Might I suggest that you post a full program, with test instructions at
the keystroke level? You will have seen how many respondents have
suggested new code rather than answering the true question.  Maybe :

program HG ;
{$IFDEF WINDOWS} uses WinCrt ; {$ENDIF}
const FNs : array [1..4] of string [30] =
  ('HG.PAS', 'NOTEXIST.PAS', 'Prof_Herbert_Gintis', 'Not_There_At_All') ;
var J : integer ; fn : file ;
begin Writeln('HG.PAS') ;
for J := 1 to 4 do begin Write('  Try ', FNs[J]) ;
  Assign(fn, FNs[J]);
  {$i-} Reset(fn) {$i+} ;
  if IOresult=0 then begin Close(fn) ;
    Writeln(' "exists"') end else Writeln(' "absent"') ;
  end {J} ;
{$IFNDEF WINDOWS} Readln ; {$ENDIF}
end.

Of course, if the problem only occurs with a PP200 CPU, I'll not find it.
--
John Stockton, Surrey, UK.  J...@merlyn.demon.co.uk  Turnpike v1.12  MIME
    http://www.merlyn.demon.co.uk/

Re:Hey, people! I'm a Good Citizen, so Why not Answer my Question???


Quote
Herbert M. Gintis wrote:

> The following code worked for me for YEARS, but now fails when I run
> the program with the internal de{*word*81} on (Pentium Pro 200):

> assign(fn,'non_existent_file');
> {$i-}reset(fn);{$i+}
> if ioresult = 0 then begin
>         do stuff when file exists....
> end;

> the program ALWAYS tell me the file exists, and opens it for input
> from the keyboard if it does not exist. This is indeed a shocker!
> Thanks

> Herbert Gintis
> Department of Economics           Phone: 413-586-7756
> University of Massachusetts       Fax:   413-586-6014
> Amherst, MA 01003
> gin...@econs.umass.edu            http://www-unix.oit.umass.edu/~gintis/

I have had the same problem until I read some documentation on this.
This code usually works fine for me:

assign(fn,'non_existent_file');
{$i-}
While IOResult<>0 do ; {ADDED LINE}
reset(fn);
{$i+}
if ioresult = 0 then begin
        do stuff when file exists....
end;

Hope this helped.
--

/Daniel Luna
mailto:ce97c...@celsiusskolan.uppsala.se

Re:Hey, people! I'm a Good Citizen, so Why not Answer my Question???


Yes, you're right, of course. However I overstated the number of times
I use it in a big program. Perhaps six or seven times, but scattered
among hundreds of lines of code. Still, I will replace the code with a
uniform function call.

Herb Gintis

\On 9 Dec 1996 07:31:02 -0700, Mike Copeland <mrc...@primenet.com>
wrote:

Quote
>Hmmmm, seems like a good trade-off to me: 200 one-line calls to a
>routine which has 3 code lines - which can be changed in _one_place_ -
>versus changing 200 lines of code scattered throughout the program and
>which has the potential of incurring at least a _few_ coding errors.
>   Making a 3-line common function a subprogram may seem silly, but when
>you code it 200 times (600 lines of actual code) - and you have to
>CHANGE it! - don't you really wish you had made it a subprogram?  Gee,
>it was more than 35 years ago when I learned how painful such an effort
>can be, and that's when I started making _any_ code I found myself
>repeating into a subprogram... 8<}}

>> Well, I'm a big fan of modularity, but not for three lines of code!

>> >> Yes, that's an alternative, and I have replaced my code with something
>> >> like yours (I'll try yours as well--I'm sure it will work). I'm just
>> >> afraid of the hundreds of places I've used the old code, which now
>> >> doesn't work!

>> >   Ahhhh - a ringing endor{*word*224}t for modularity and TP/BP Units, I'd
>> >say!  If you had designed your applications with this common function in
>> >one place, callable from anywhere, you'd have not problem, would you?
>> >   Sorry to embarrass you, but this should be a good object lesson for
>> >younger "students" here, I feel...

Herbert Gintis
Department of Economics           Phone: 413-586-7756
University of Massachusetts       Fax:   413-586-6014
Amherst, MA 01003
gin...@econs.umass.edu            http://www-unix.oit.umass.edu/~gintis/
Go to page: [1] [2]

Other Threads