Re: binding to non-existent file
Peter <[email protected]> Thu, 31 Mar 2016 12:51:08 +0100
| Newsgroups | gmane.comp.compilers.gpc |
|---|---|
| Message-ID | <[email protected]> |
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 > [email protected] > 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. ---------------------------- _______________________________________________ Gpc mailing list [email protected] https://www.g-n-u.de/mailman/listinfo/gpc