> On Jan 3, 2017, at 10:08 PM, Schneider <schneidt@mail.nih.gov> wrote:
>
> Leo:
>
>> https://sourceforge.net/p/p2ada/code/HEAD/tree/
>> http://p2ada.sourceforge.net/pascada.htm
>
> I looked into this last July. I got the converter going and I got the
> compiler running. My final note:
>
>> 2016 Jul 18
>>
>> Currently hung because ada cannot handle files other than input and output.
>> That is, it crashes if one tries to writeln(afile, 'something');
>
> Example:
>
> program shell(afile, output);
> var
> afile: text;
> begin
> rewrite(afile);
> writeln(afile, 'shell output');
> end.
>
> This produces a file called 'afile' with contents 'shell output'. It
> compiles with FPC and translates to c and compiles with p2c. Ada
> can't handle it. I suspect there is a way to do it but could not find
> the documentation.
Hmm... While I don't know Ada well enough to be even considered dangerous, I think the solution you're looking for lies in Ada'a Ada.Command_Line package which has the procedures that provide for reading the command line parameter text file name that Pascal's runtime system automatically associates to the "afile" file variable. Once you have the name then you use Ada.Text_IO package's procedures to create the file and output to it.
Ada'a mechanism for connecting to external command line parameters has more of a C argv argc style of parameter associating mechanism than Pascal's program parameter list of file variable names where the runtime system automatically associates the external command line parameter with the program's internal fileparameter.
I'm not sure how Ada's file handling procedures deal with the legal usage possibilities of Pascal's rewrite procedure. Rewrite does the "Right thing" regardless whether the file already exits or not. I don't know if both cases are automatically handled by Ada's runtime system in a similar Pascal runtime system manner or if you have to check which case you have and then have code to deal separately with each case.
Gale Paeper
gpaeper@empirenet.com
_______________________________________________
Gpc mailing list
Gpc@gnu.de
https://www.g-n-u.de/mailman/listinfo/gpc