[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to Delete and Rename of Files
From: |
Gaius Mulley |
Subject: |
Re: How to Delete and Rename of Files |
Date: |
Mon, 30 Dec 2019 05:39:15 +0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
Johannes Slotboom <address@hidden> writes:
> Dear all,
>
> I am trying to get my old Logitech Modula-2 code from the end of the
> eighties begin nineties of last century working again using the gm2
> compiler.
>
> Nearly everything compiles now BUT a few compiler errors that concern
> deleting and renaming of files are persistent and I do not know how to
> fix.
>
> I make the following imports:
>
> FROM FIO IMPORT OpenForRandom, OpenToRead, OpenToWrite, WriteNBytes,
> File, Close, ReadNBytes;
>
> With above imports I can create files etc. and this compiles.
>
> In order to Delete and Rename files I also import additionally:
>
> FROM FileSystem IMPORT Delete, Rename;
>
> But if I compile my file (having both FIO and FilesSystem imports).
>
> With my statement
>
> Rename(out,'dm.bin');
>
> I want to do the renaming of the file, but I get following error of
> gm2:
>
> /home/slotboom/opt/lib/gcc/x86_64-pc-linux-gnu/8.2.0/m2/log/FileSystem.def:110:11:parameter
> mismatch: identifier with an incompatible type is being passed to this
> procedure
> ./ilv.mod:698:7: error: error found while compiling the program module
> ./ilv.mod:698:7:problem in parameter 1, PROCEDURE Rename (VAR f: File;
> ... ) ;
> ./ilv.mod:698:7:item being passed is 'out': File
> ./ilv.mod:698:7:parameter mismatch: identifier with an incompatible
> type is being passed to this procedure
>
> What I do not understand is that out is of type VAR File.
>
> Last information I compile my file with following statement:
>
> slotboom@JS-at-Asus:~/development/ILV/SRC$ gm2 -g -c -
> I/home/slotboom/opt/lib/gcc/x86_64-pc-linux-gnu/8.2.0/m2/log -
> I/home/slotboom/opt/lib/gcc/x86_64-pc-linux-gnu/8.2.0/m2/min -
> I/home/slotboom/opt/lib/gcc/x86_64-pc-linux-gnu/8.2.0/m2/pim -
> flibs=logitech ./ilv.mod
>
> Is there someone who knows who to do renaming and deleting of files,
> while also using FIO?
> I would highly appreciate it!
>
> regards
>
> Hans
Hi,
sure I think this example might help:
MODULE rename ;
FROM FileSystem IMPORT File, Response, Lookup, Rename, Close, SetWrite ;
IMPORT FIO ;
VAR
f, s: File ;
BEGIN
Lookup (f, "first.txt", TRUE) ;
IF f.res = done
THEN
SetWrite (f) ;
FIO.WriteString (f.fio, "hello world") ;
FIO.WriteLine (f.fio) ;
Close (f) ;
Lookup (f, "first.txt", FALSE) ;
Rename (f, 'second.txt') ;
Lookup (s, "second.txt", FALSE) ;
IF s.res = done
THEN
HALT (0)
END
ELSE
HALT
END
END rename.
I've included this into the regression testsuite:
http://git.savannah.gnu.org/cgit/gm2.git/tree/gcc-versionno/gcc/testsuite/gm2/pimlib/logitech/run/pass/rename.mod
I think the error message you had regarding File was due to an attempt
to pass an actual parameter FIO.File as a formal parameter
FileSystem.File. I believe the error message has been improved in the
gm2 master which grafts onto gcc trunk (gcc-10)
regards,
Gaius