On 31/03/16 06:20, Paul Isaacs wrote:
Hello,
I am following the example from page 94 of the GNU pascal manual.
bind( f,b); b := binding( f );
b.bound appears to be true even though the file does not exist although the example indicates otherwise.
I have duplicated the example - it finds a non-existent file.
Is the example wrong ( the same example is in the standard )?
Regards,
Paul Isaacs
Gpc mailing list Gpc@gnu.de https://www.g-n-u.de/mailman/listinfo/gpc
I suspect that for b.bound to be true just needs a valid file name (like the Borland Pascal assign). b.Existing should be used to check for file existance.
The full example (I've not tried it) from page 110 of the manual is here
---------------------------- procedure BindFile (var f: Text); var b: BindingType; begin Unbind (f); b := Binding (f); repeat Write (âEnter a file name: â); ReadLn (b.Name); Bind (f, b); b := Binding (f); if not b.Bound then WriteLn (âFile not bound -- try again.â) until b.Bound end;
begin BindFile (f); { Now the file f is bound to an external file. We can use the implementation defined fields of BindingType to check if the file exists and is readable, writable or executable. } b := Binding (f); Write (âThe file â); if b.Existing then { <<-- **************************** } WriteLn (âexists.â) else WriteLn (âdoes not exist.â); Write (âIt is â); if not b.Readable then Write (ânot â); Write (âreadable, â); if not b.Writable then Write (ânot â); Write (âwritable and â); if not b.Executable then Write (ânot â); WriteLn (âexecutable.â) end. ----------------------------