Peculiarity with FindFirst and CON. 
Author Message
 Peculiarity with FindFirst and CON.

I have two programs, HUNT and FILGEN, which use FindFirst, HUNT also
uses FindNext.  16-bit FILGEN cannot see CON - why?

HUNT is TP5 compatible, compiled with BP7 real mode.
FILGEN16 is FILGEN.PAS compiled with BP7 real mode.
FILGEN32 is FILGEN.PAS compiled with delphi 3 console mode.

HUNT CON returns
                 2002/12/07-21:56:14 CON     .          666 ......T.
FILGEN16 CON gives
                FILGEN16: Name "con" not found, DosError=3  EL=2.
FILGEN32 CON gives (on one line)
                2002-12-07 21:57:50 CON.                    666
                                        .........  "C:\pas-prog\CON"

That's in a Win98 DOS box.

In DOS6.20, HUNT gives similar, but 54849 bytes; and FILGEN16 gives
similar, but DosError=18.

Similarly with NUL instead of CON.

It would be nice to understand this, and nicer if FILGEN16 would work
with CON.

Any thoughts?

Neither used FileMode; setting FileMode := 0 makes no difference.

DOSERROR :
     2 File not found
     3 Path not found
    18 No more files

--

 Web  <URL: http://www.*-*-*.com/ ; - FAQqish topics, acronyms & links.
 PAS EXE TXT ZIP via <URL: http://www.*-*-*.com/ ;.
 Do not Mail News to me.    Before a reply, quote with ">" or "> " (SoRFC1036)



Thu, 26 May 2005 06:11:15 GMT  
 Peculiarity with FindFirst and CON.
What parameters do y<ou give FINDFIRST?
Do you operate on the same directory? Which one? Root?

Greetings

Markus



Thu, 26 May 2005 17:37:12 GMT  
 Peculiarity with FindFirst and CON.



Quote:


> posted at Sun, 8 Dec 2002 10:37:12 :-
> >What parameters do y<ou give FINDFIRST?
> >Do you operate on the same directory? Which one? Root?

> The given name, Anyfile or $3F, and a record.  It uses the current
> directory, which is not root.

I assume you knew that CON is a reserved word in DOS.  It is treated as
a file but it refers to the keyboard. This is probably not the same as
the console mode in Delphi.
BP/TP usually has it's own routines for dos calls, therefore I don't
think that you can find it with findfirst, since that will try to find
the keyboard on the HD.
E.g. in DOS if you type.

COPY CON Myfile.txt
this is the text.
<ctrl> Z

you get the answer
1 file copied
Type DIR and you will see that you have created the file Myfile.txt

If you want to have a command line parameter string CON, you must simply
discriminate it from the parameter list, and react to it in the ordinary
way with readkey etc. Or perhaps you can reassign the standard input to
a file in case the paramstring is NOT equal to CON

Program tesinput(input,output);
uses dos;
var  s:string;
begin
  if paramstr(1)<>'con' then assign(input,'myfile.txt');
  {$I-}
  reset(input);
  {$I+}
  while not eof(input) do
  begin
    readln(s);
    writeln(s);
  end;
  close(input)
end.

Run it with con as parameter and it will display any text typed on the
keyboard and will do so until you type <ctrl>Z    (=eof)
Run it with any other filename and it will display the contents of that
file.

--
Femme



Sat, 28 May 2005 08:22:42 GMT  
 Peculiarity with FindFirst and CON.


Quote:


> Dec 2002 01:22:42 :-





> >> posted at Sun, 8 Dec 2002 10:37:12 :-
> >> >What parameters do y<ou give FINDFIRST?
> >> >Do you operate on the same directory? Which one? Root?

> >> The given name, Anyfile or $3F, and a record.  It uses the current
> >> directory, which is not root.

> >I assume you knew that CON is a reserved word in DOS.

> I assumed that we all know that.

> >  It is treated as
> >a file but it refers to the keyboard. This is probably not the same as
> >the console mode in Delphi.

> In Delphi, what is found is not a true file; the *current* time is
> shown.

> >BP/TP usually has it's own routines for dos calls, therefore I don't
> >think that you can find it with findfirst, since that will try to find
> >the keyboard on the HD.

> As I said before, HUNT is also a 16-bit BP7 program, and finds CON - the
> same CON as Delphi, AFAICS.

> >If you want to have a command line parameter string CON, you must simply
> >discriminate it from the parameter list, and react to it in the ordinary
> >way with readkey etc.

> This is not a matter of reading the contents of CON; these programs read
> directory entries only.  But a CON 'file' is standard input; it does not
> use ReadKey.  Crt is *absent* from these programs.

> The problem is one of why the 16-bit BP7 program FILGEN fails to see CON
> with FindFirst, when the 16-bit BP7 program HUNT sees CON and the 32-bit
> D3 console mode program FILGEN also sees CON - all being run in the same
> Win98 DOS box.

> FILGEN16 cannot see CON or con.

> None of them, however, show CON on being asked for CO* or CO*.*.

> I am reminded that, given CON, HUNT actually seeks CON.* and finds CON;
> given CON., it seeks CON. and finds CON.

> FILGEN32, given CON or CON., finds; but does not find for CON.*.

> FILGEN16 finds for none of those.

> The problem is the *difference* between the two 16-bit versions, and
> that between FILGEN 16 & 32, while HUNT (16) matches FILGEN32.

I have often noticed that Windows assigns files and devices not to 16 bit programs, but to the dos box it is running in.
The file stays locked or invisible to other 16 bit programs until the box closes. Regardless of the file being closed or not.
E.g. if you develop a graphic program in the IDE and did test run it, if you try to run the program standalone in another Dos box,
it will be unable to find the .bgi driver. You have to close the IDE first before it will run. The same for a Com port. The
situation does not exist if you successively run two programs that try to reach the Com port both from within the same Dos box.
Also this situation is not always the case. e.g. you can open more than one IDE with the same files in it, but I remember having
problems with a debug log file.

--
Femme



Sun, 29 May 2005 21:58:21 GMT  
 Peculiarity with FindFirst and CON.
hi

Quote:
>> I assume you knew that CON is a reserved word in DOS.

> I assumed that we all know that.

and 'con' is a really tricky one ;-)

Quote:
> HUNT & FILGEN ZIPs via sig line 3.

i got the files from your site.

begin of your mainprogram in hunt.pas:

| BEGIN ;
| Assign(Scrn, 'CON') ; Rewrite(Scrn) ;

might this cause the difference?

i'm using w2k and "hunt CON" returns 0 machtes.

on your exe, on a recomliled tp7-exe and even when using the version
without your rewrite ...

but dosbox w98 and dosbox w2k are really different.

hth
jochen



Mon, 30 May 2005 04:20:22 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Help with c:/con/con HELP!!! PLEASE

2. SQL - peculiarity, Bug or...?

3. D3 BDE installation peculiarities and file locations

4. Problemi con Interbase 6.

5. Interbase 4.2 con delphi 3.0

6. ClientDataSets con Delphi5 Enterprise

7. Problemas con fechas en Access

8. How con I set the colour of every second line in a dbgrid

9. WAV Format Problem / Problema con Formatos WAV

10. problema con los qrdbtext

11. Pascal Pros/Cons Vs. C, C++, Java

12. Replacement for BP7 - pros & cons needed

 

 
Powered by phpBB® Forum Software