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(a)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(a)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.