Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!dali!uakari.primate.wisc.edu!aplcen!haven!decuac!shlump.nac.dec.com!hiyall.enet.dec.com!reagan From: reagan@hiyall.enet.dec.com (John R. Reagan) Newsgroups: comp.lang.pascal Subject: Re: Read Files, How? Message-ID: <12056@shlump.nac.dec.com> Date: 30 May 90 17:12:14 GMT Sender: newsdaemon@shlump.nac.dec.com Organization: Digital Equipment Corporation Lines: 50 In article <50800002@uxa.cso.uiuc.edu>, jlg0805@uxa.cso.uiuc.edu writes... > >On standard Pascal, how can one interactively input a file name, then >ask the program to read the file; ask the program to load another >file and repeat the same thing. > >as my understanding, the external file name shoud appear in the program >header. However, this only works if actually there is a file with that >very name. If files have different names, then the machine gives an >error. (mine is a sequent running unix), telling me "file not existent" >or something like that. > >how to solve this problem? i hope it is not that one recompiles the >program for each new file. > > >--The profs never teach useful practical things but stuff like AVL trees > in class. :-( > >J.Liang >jlg0805@uxa.cso.uiuc.edu > > > Unextended Pascal (aka classic standard Pascal) had static binding of files in the program header to external files in the file system. It is upto an implementation to tell you how to set up this binding (like setting up aliases or environment variables, etc.) However, it is still static for that invocation of the image. You want dynamic binding (the ability to break a binding and recreate a new one in the same program based on some user input). The sad news is that you can't do that in old unextended Pascal. You'll have to rely on vendor extensions (such as OPEN routines, etc.) or run the program over again with a different static binding (I wouldn't think you'd have to recompile). In the Extended Pascal standard, there are now new routines called BIND and UNBIND that perform much the same concept as some OPEN extensions. Extended Pascal's binding allows you to do exactly what you want (of course all file operations are implementation-defined in the sense that filenames on one system might not be the same on other system...). --- John Reagan Digital Equipment Corporation reagan@hiyall.dec.com ---