Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2002-07

OS/2 FindFirst/FindNext problem

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Rolf Grunsky

I have written a small utility that reports any filenames that are too long for a CD (64 characters.) It displays the length and name of any filename that is too long or if all the filenames are legal, it reports the length of the longest name.

This program compiles and runs properly with the Win32 version of the compiler (1.0.6) but fails to run when compiled and run under OS/2. The same program compiles and runs properly when compiled with Virtual Pascal.

Program CheckCDName;
Uses SysUtils;
Var
  Sr : TSearchRec;
  SCode : Integer;
  ErrCount : Integer;
  SMask : String;
  MaxLen : Integer;
Function Plural(Count : Integer; Singular, Plurals : String) : String;
Begin
  If Count = 1 Then Plural := Singular Else Plural := Plurals;
End; { Plural }
Begin
  Assign(Output, '');
  rewrite(Output);
  If (ParamCount = 0) Then SMask := '*'
  Else SMask := ParamStr(1);
  ErrCount := 0;
  MaxLen := 0;
  {WriteLn('Searching on : ', SMask);}
  SCode := FindFirst(SMask, faAnyFile, Sr);
  {WriteLn('SCode : ', SCode);}
  While (SCode = 0) Do
  Begin
    {WriteLn(Sr.Name);}
    If (Length(Sr.Name) > MaxLen) then MaxLen := Length(Sr.Name);
    If (Length(Sr.Name) > 64) Then
    Begin
      WriteLn(Length(Sr.Name):3, ' ', Sr.Name);
      Inc(ErrCount);
    End;
    SCode := FindNext(Sr);
    {WriteLn('SCode : ', SCode);}
  End;
  FindClose(Sr);
  If (ErrCount = 0) Then WriteLn('No invalid names (', MaxLen, ')')
  Else WriteLn(ErrCount, ' Invalid ', Plural(ErrCount, 'name',
'names'));
    Close(Output);
End.

The output with debug statements is :

Searching on : *
SCode : -87
No invalid names (0)

With the debugging write statements uncommented, the result from the FindFirst was always -87. Is this a FindFirst bug or am I missing something?

Cheers

Rolf Grunsky

RGrunskyAtSympaticoDotCa Truth in her dress finds facts too tight. In fiction she moves with ease. Rabinranath Tagore

Reply by email

Unknown author
to Rolf Grunsky

Date sent: Tue, 09 Jul 2002 23:42:39 -0400
From: Rolf Grunsky
To:
Subject: [fpc-pascal]OS/2 FindFirst/FindNext problem Send reply to:

.
.

SCode := FindFirst(SMask, faAnyFile, Sr);

.
.

Show quoted text 10 lines
The output with debug statements is : Searching on : * SCode : -87 No invalid names (0) With the debugging write statements uncommented, the result from the FindFirst was always -87. Is this a FindFirst bug or am I missing something?

It's a FindFirst bug, thanks for your report. I've fixed it, but can't commit it until tomorrow because our CVS repository is down currently (as announced by Jonas here as well).

Tomas

Reply by email