On 15/04/15 16:12, Allin Cottrell wrote:
On Wed, 15 Apr 2015, Sven Schreiber wrote:
> Am 15.04.2015 um 09:48 schrieb Ignacio Diaz-Emparanza:
>> On 14/04/15 02:22, oleg_komashko(a)ukr.net wrote:
>>> In GUI for a function package I had to do like this
>>>
>>> then the function read "-1"
>>> and computes 12*($nobs/100)^1/4
>>>
>>> How to make the default value to make the function to show computed
>>> value of 12*($nobs/100)^1/4, for example 10, as adf GUI do in this
>>> window?
>>
>> Good question !!
>> I don't know and I am also interested in a response.
>
> I don't even know whether I know the answer (probably not) because I
> haven't really understood the question...
It's about presenting a default value "nicely" to the user in the GUI
context. It's easy to write a function that interprets a lag order of
-1 on input as a signal to compute the order via some default formula,
but how can you show the user in advance what the formula would yield?
We can do that in the gretl GUI itself, just by applying the formula
to the case in hand and putting the number it yields into the dialog
box. At present, however, there's no way for a function package writer
to achieve the same effect. You can supply a default value for a
parameter OK, but it must be a constant. To allow what's being
requested we'd have to generalize the mechanism to allow a formula for
the default (with access to $-accessors).
Allin
It might be playing with strings. For example, I am seeing this is
working, but I don't know whether this may be packaged (and I have no
time for trying, I must go home now).
<hansl>
string a = sprintf("%.2g", $pd)
function scalar itworks(scalar seas[@a])
scalar err = (seas=$pd) ? 1 : 0
return err
end function
scalar doitwork=itworks()
</hansl>
-- Ignacio Díaz-Emparanza Dpto. de Economía Aplicada III (Econometría y
Estadística) UPV-EHU
http://www.bl.ehu.es/~etpdihei/
end function
--
Ignacio Díaz-Emparanza
Departamento de Economía Aplicada III (Econometría y Estadística)
Universidad del País Vasco, UPV/EHU
http://www.ehu.eus/ea3