On Wed, 9 Oct 2013, Pindar Os wrote:
Hi there,
I found some infos how to use the getenv() function in the manuel for e.g.
'USER'. Did you mean that Jack?
I think in terms of an automatic parse fucntion the getline() fucntion
would be needed and sscanf().
Here's the sort of thing that Jack had in mind:
<hansl name="getenv.inp">
# get stuff from the environment
scalar num01 = ngetenv("num01")
string strdir = getenv("strdir")
print num01
print strdir
</hansl>
At the shell prompt:
num01="100" strdir="c:\\" gretlcli -b getenv.inp
<gretl-output>
? scalar num01 = ngetenv("num01")
Generated scalar num01 = 100
? string strdir = getenv("strdir")
Generated string strdir
? print num01
num01 = 100.00000
? print strdir
c:\
Done
</gretl-output>
However, to return to your original question -- "ever thought of offering
a 'parse function' that automatically recognizes variables presented in
this form in a txt file...?", that's what "include" does.
<hansl name="auxfile.inp">
scalar num01=100
string strdir="c:\\"
</hansl>
<hansl name="includeit.inp">
include auxfile.inp
print num01
print strdir
</hansl>
Allin
2013/10/7 Riccardo (Jack) Lucchetti <r.lucchetti(a)univpm.it>
> On Mon, 7 Oct 2013, Pindar wrote:
>
> Btw, ever thought of offering a 'parse function' that automatically
>> recognizes variables presented in this form in a txt file:
>>
>> scalar num01=100
>> string strdir="c:\\"
>> ...
>>
>> I ask since it would be a way similar to R batch files where one can pass
>> arguments.
>>
>
> I suspect you'll find the getenv() and ngetenv() functions very nice.