I was a co-author of an algorithm written in Pascal (ISO 7185) which read:
PROGRAM stvpas(datafile, output);
{This program counts the votes in a Single Transferable Vote election, using Meek's method, and reports the results}
...
The datafile was reread on every iteration of the algorithm.
Am I correct in stating that that the program cannot be run with gpc without making a change to the program to assign datafile to an external file?
Brian.
On Thu, Jan 19, 2006 at 09:37:43PM +0000, Brian Wichmann wrote:
I was a co-author of an algorithm written in Pascal (ISO 7185) which read:
PROGRAM stvpas(datafile, output);
{This program counts the votes in a Single Transferable Vote election, using Meek's method, and reports the results}
...
The datafile was reread on every iteration of the algorithm.
Am I correct in stating that that the program cannot be run with gpc without making a change to the program to assign datafile to an external file?
Brian.
No. You may reread a file any times by resetting it before each iteration. It does not matter whether it was assigned explicitely or through a program parameter.
Emil Jerabek
Dear Emil,
How to I assign the program parameter to an external file without changing the source text?
On 19 Jan 2006, at 22:37, Emil Jerabek wrote:
No. You may reread a file any times by resetting it before each iteration. It does not matter whether it was assigned explicitely or through a program parameter.
Brian Wichmann wrote:
How to I assign the program parameter to an external file without changing the source text?
Either (guess we should document that):
stvpas --gpc-rts=-ndatafile:myfile.dat
(--gpc-rts=-h for help)
Or:
Compile with `--transparent-file-names'. Then it will always open the external file called `datafile' (without suffix). Maybe not what you want.
Or:
Otherwise the program will ask for the file name at run time (on the terminal, not standard input by default).
Frank
Brilliant! I scanned the documentation several times and did not find this... Brian.
On 19 Jan 2006, at 23:25, Frank Heckenbach wrote:
Either (guess we should document that):
stvpas --gpc-rts=-ndatafile:myfile.dat
(--gpc-rts=-h for help)
Or:
Compile with `--transparent-file-names'. Then it will always open the external file called `datafile' (without suffix). Maybe not what you want.
Or:
Otherwise the program will ask for the file name at run time (on the terminal, not standard input by default).
Frank
On Thu, Jan 19, 2006 at 10:49:06PM +0000, Brian Wichmann wrote:
Dear Emil,
How to I assign the program parameter to an external file without changing the source text?
On 19 Jan 2006, at 22:37, Emil Jerabek wrote:
No. You may reread a file any times by resetting it before each iteration. It does not matter whether it was assigned explicitely or through a program parameter.
Sorry, I misunderstood where the problem was. There are at least three ways to do it:
- Just compile the program as it is, and run it, it will prompt for a file name.
- Give the program a command-line option like this,
stvpas --gpc-rts=-ndatafile:data
it will assign the file "data" to the parameter "datafile".
- Give the compiler the option "--transparent-file-names", then the program will assign file "datafile" to the parameter "datafile".
Emil