Defining a parameter for UDF
Hi all,
I have a UDF which requires a constant, real parameter. Is there a way to give this parameter a value, without having to modify and recompile the source? Thanks, Philipp |
Hi,
refer to: "Defining a Scheme Variable in the Text Interface" & "Accessing a Scheme Variable in a UDF" in UDF manual. |
Thanks a lot, Amir!!
Is there a way to check whether a variable (with the given name) has been defined in the TUI? The manual shows how to check this in TUI (which is already quite useful). But I would like to do the same in the UDF, something like int myVar; ... if(isDefined("variable-name") myVar = RP_Get_Integer("variable-name"); else myVar = DefaultValue; |
I'm not sure, but if you check whether the retrieved value in UDF is equal to NULL or not, may help you.
|
A call RP_Get_Real with an invalid scheme variable name produces a runtime error :(
|
Quote:
|
I use the following construction
int ret=0; const int default_value; ... ret = (int) CX_Interpret_String("( (if (rp-var-object 'var-name)) (%rpgetvar 'var-name))"); if(!ret) ret = default_value; return ret; The UDF shows correct behaviour, but it returns error messages Error : eval : unbound variable Error object: %rpgetvar These error messages make the execution extremely slow (but do not terminate it!). How can I avoid it? I have no idea of scheme programming, can anyone suggest me how to write a line that does " if variable "var_name" is defined, return 1, else return 0 " |
Quote:
CX_Interpret_String("(if (rp-var-object 'var-name) (rpgetvar 'var-name)(rpsetvar 'var-name default-value))"); ret=RP_Get_Integer("var-name"); |
Quote:
I also tried CX_Interpret_String("(if (not (rp-var-object 'var-name))(rp-var-define 'var-name default-value 'integer #f))"); ret=RP_Get_Integer("var-name"); but it gives me an error "var-name" undefined variable. I should also mention that I am using a compiled UDF. Can it be that I need to include certain headers that are not present in udf.h? |
Quote:
CX_Interpret_String("(if (not (rp-var-object 'var-name))(rp-var-define 'var-name -1 'integer #f))"); ret=RP_Get_Integer("var-name"); |
Quote:
Yes, that's what I meant. In the actual code, I have something like CX_Interpret_String("(if (not (rp-var-object 'var-name))(rp-var-define 'var-name -1 'integer #f))"); The error still occurs. |
Quote:
|
All times are GMT -4. The time now is 01:45. |