Sign in Join

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

Mailing lists / fpc-pascal / 2019-10

*etFTime -> File*etDate

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

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

Ched

Hello,

In https://www.freepascal.org/docs-html/rtl/sysutils/filenameroutines.html ,

FileSetDate <https://www.freepascal.org/docs-html/rtl/sysutils/filesetdate.html>Get file dates  should be corrected to _S_et .

Now, my real problem is that the following code is compiled when SYS is not defined, and isn't when it is, and I really don't know why.

PROGRAM QQ;
    { $DEFINE SYS}
USES
    {$IFDEF SYS}
       SYSUTILS;
    {$ELSE}
       DOS;
    {$ENDIF}
VAR
    FO: FILE OF DOUBLE;
    L: LONGINT;
BEGIN
    ASSIGN(FO, 'blabla.bin');
    RESET(FO);
    {$IFDEF SYS}
       L:=FILEGETDATE(FO);   { Got File, expected LongInt }
    {$ELSE}
       GETFTIME(FO, L);
    {$ENDIF}
    CLOSE(FO);
END.

Well, it appears that I prbably haven't fully understand the dos->sysutils conversion.

Cheers, Ched'

Reply by email

Christo Crause
to Ched

On Sun, Oct 13, 2019 at 8:03 PM Ched <

Show quoted text 12 lines

I don't see any mix-up of Get and Set on either the FileSetDate or FileGetDate pages at your link above.

Show quoted text 26 lines
Now, my real problem is that the following code is compiled when SYS is not defined, and isn't when it is, and I really don't know why. PROGRAM QQ; { $DEFINE SYS} USES {$IFDEF SYS} SYSUTILS; {$ELSE} DOS; {$ENDIF} VAR FO: FILE OF DOUBLE; L: LONGINT; BEGIN ASSIGN(FO, 'blabla.bin'); RESET(FO); {$IFDEF SYS} L:=FILEGETDATE(FO); { Got File, expected LongInt } {$ELSE} GETFTIME(FO, L); {$ENDIF} CLOSE(FO); END.

The file variable FO in your code should be declared as type THandle (which is an alias for LongInt) when you are using the SysUtils file handling routines. Take a look at the example at the bottom of FileCreate ( https://www.freepascal.org/docs-html/rtl/sysutils/filecreate.html) to see how to work with these routines.

Well, it appears that I prbably haven't fully understand the dos->sysutils conversion.

You are mixing classic Pascal style file handling (Assign, Reset, Close) which isn't (AFAIK) Dos style, with an alternative file handling style defined in SysUtils.

Cheers, Ched'

Reply by email