Daniel,
Can you see q in the scalars list which can be accessed through the icon view, which can be accessed through the GUI: view->icon view? Also could you use the
print command, i.e. print q (or you might look up printf if you want to format the output)
Logan
P.S. Peter, thanks for the syntax correction.
From: gretl-users-bounces@lists.wfu.edu [mailto:gretl-users-bounces@lists.wfu.edu]
On Behalf Of Summers, Peter
Sent: Friday, August 17, 2012 9:55 AM
To: Gretl list
Subject: Re: [Gretl-users] function Command
Daniel,
There are actually 2 problems here:
1)
You have an extra comma after p – change (scalar p,) to (scalar p). The comma makes Gretl think there are more input arguments coming, hence the ‘missing
type identifier.’
2)
Re Logan’s suggestion, you need to assign a value to q before the return command.
The following works on my (Win 7) machine:
function scalar model(scalar p)
q = 3*p
return q
end function
HTH,
PS
From:
gretl-users-bounces@lists.wfu.edu
[mailto:gretl-users-bounces@lists.wfu.edu]
On Behalf Of Daniel Sirim
Sent: Friday, August 17, 2012 8:20 AM
To: gretl-users@lists.wfu.edu
Subject: [Gretl-users] function Command
Hello ,
i have got a new question refering to the “function” command.
First of all I want to understand the Syntax of this command. I read the Guide and check the syntax but why is it not working?
genr p = 3
function scalar Model( scalar p,)
q= 3*p
end function
just a small example but to get to understand it. It says : expected a type identifier…. But why ? there is the name of the Function called Model and also the type … scalar…. What is wrong with that?
If I got this, it is my aim to built an Modular System, which means, First on the upper side of the script I want to have the basic formulas, like
1.
function series AB (series a, scalar b, scalar c, scalar d)
a*(1-exp(-b*(c-c0)))
end function
2.
Function …..
3.
Function …..
And so on …
After declaring and defining the parameters und the function body of the basic formulas, I want to stick them together, I need it like this because it depends on the case which basic function I need and also
the sequence could be different ( for example: case 1: 2. Formula + 3. Formula + 2. Formula…. Case 2: 3.Formula + 1.Formula …)
My Other Question is is it possible to make this "combinedfunction" easier to write ?
What I mean is let the commands like series oder scalar away, cause its also declared.
Hopefully somebody can help me I thing there will be some other question but I think for the first round it more then enough.
Thank you, and I hope for some answers =)
Daniel.