PS: A work-around is of course possible, like the following.

 

Work-Around:

function bundle get_defaults() #get a local copy of the defaults, can be used in a function if no options provided, or to create a local copy of the defaults bundle which then can be modified …

 

function void modify_defaults(bundle *local_defaults) #can modify a copy of local defaults

 

function plot(bundle input[null] “input”, string plot-type[null] “specify plot”, string output[null] “specify output name.type, default: display” bundle options[null] “local version of modified options, if wished for”) #if all is null, a help will be printed.

 

Best

Frederik

 

Von: gretl-users-bounces@lists.wfu.edu [mailto:gretl-users-bounces@lists.wfu.edu] Im Auftrag von Schaff, Frederik
Gesendet: Montag, 8. Januar 2018 11:30
An: Gretl list (gretl-users@lists.wfu.edu) <gretl-users@lists.wfu.edu>
Betreff: [Gretl-users] function - pass global string variable via pointer

 

Hi there,

 

from hansl-primer p. 36 it is clear there are no global variables.

 

Is there any way to circumvent this? For example by using default options defined outside the function body and passing them with pointers to the function body? I would like to have a function to “set” some global options for the plotting package I am working on. However, to do so, I need to define a kind of global container (a bundle, e.g.) with the default values, upon which the function can then work (a) and whose values I can also load, say as defaults in the function header, to other functions (b). Finally (c), is there an option to define pointer-type string variables and pass pointers to a string?

 

Best

Frederik