Hello,
Are program parameters tied in any way to command line parameters?
Is it possible to set BindingType.Name from the command line using a program parameter?
program( a ...
var a : bindable Text; b : BindingType;
begin b := Binding( a ); Bind( a, b );
where b.Name has been set from the command line.
Thank you, Paul Isaacs
Le 16/01/2017 à 20:20, Paul Isaacs a écrit :
Are program parameters tied in any way to command line parameters?--
No, *program* parameters are a misconception of the original ISO7185 pascal standard, kept in the ISO1026 extended program standard. They are a misconception because they are "implementation dependent" in both standards, which means they fool one main goal of pascal, portability. Accessing *command line* parameters is usually made through Borland Pascal extensions ParamCount and ParamStr, which are not contained in any standard ... See, e.g. the following non conformant modification of BindingDemo.pas (contained in the gpc doc) which was originally ISO10216 conformant ------------------------------------------------------------------- program BindingDemo (Input, Output, f);
var f: bindable Text; b: BindingType;
procedure BindFile (var f: Text); var b: BindingType; begin Unbind (f); b := Binding (f); b.Name:=ParamStr(1); {... here it is ...} Bind (f, b); b := Binding (f); if not b.Bound then WriteLn ('File not bound -- try again.') 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. -------------------------------------------------------- Hope this helps
Maurice Lombardi Laboratoire Interdisciplinaire de Physique (LIPhy) Universite Grenoble Alpes & CNRS - Pôle Phitem Bat E - 140 rue de la physique 38400 Saint Martin d'Heres FRANCE
Fax: 33 (0)4 76 63 54 95 mailto:Maurice.Lombardi@univ-grenoble-alpes.fr
Paul Isaacs wrote:
Hello,
Are program parameters tied in any way to command line parameters?
There is a nonstandars GPC extension so that you can set them using '--gpc-rts' option to the program (see GPC reference documentation for more detail). As Maurice wrote for portablity it is better to avoid such use.
Is it possible to set BindingType.Name from the command line using a program parameter?
program( a ...
var a : bindable Text; b : BindingType;
begin b := Binding( a ); Bind( a, b );
where b.Name has been set from the command line.
Probably, you should just check if this works.
Maurice and Waldek,
Thank you for your replies.
The --gpc-rts option is what I need to keep the source code 10206 compliant but allow an external file name to be accessed.
I am attempting write a 10206 compliant lexical analyzer using 10206 compliant code and I needed a way to make a file name to be scanned available to the program. The code remains compliant but has a compiler dependency.
The only other way I can see is to put the source file name inside a file with a name that is specified by the analyzer and then read the specified file to get the source file name. This may not be all that bad because the specified file could also contain the names of directories to search for modules and/or other external parameters.
Thanks again,
Paul Isaacs