rosalbaperez
8th July 2003, 02:58
Is it possible to create referential variables or dynamic variables in Baan?

meaning... can I create the name of the variable on runtime and then get the value? I remember doing this in C but haven't seen it in Baan.

Does Baan handle this?

Thanks
Rosalba

NPRao
8th July 2003, 03:15
Rosalba,
can I create the name of the variable on runtime and then get the value? I remember doing this in C
I am not sure what do you mean there? do you mean the Pointers from C(*) or References (*, &) to objects from C++ ? I dont think you can create a variable at runtime even in C or C++ but you can create objects with dynamic memory allocations (malloc, calloc, constructors, destructors etc) based on the datatype/class/templates. Can you please be more clear ?

There are no pointers in BaaN Tools. But you can declare, based variable and allocate the size dynamically, or reallocate.

Refer to the links-

alloc.mem() (http://www.baanboard.com/programmers_manual_baanerp_help_functions_memory_operations_alloc_mem)

Fixed and based variables (http://www.baanboard.com/programmers_manual_baanerp_help_3gl_features_fixed_and_based_variables)

expr.compile() (http://www.baanboard.com/programmers_manual_baanerp_help_functions_expressions_runtime_expr_compile)

But you have a feature similar to pointers in BaaN Tools, refer to -

at.base() (http://www.baanboard.com/programmers_manual_baanerp_help_functions_variables_based_at_base1)

Variables (based) overview and synopsis (http://www.baanboard.com/programmers_manual_baanerp_help_functions_variables_based_overview_and_synopsis)
Use the at.base() function to base one variable (the based variable) on another variable (the basic variable). Both variables then use the same memory area.

gguymer
8th July 2003, 16:04
I think you might be interested in these functions:

Functions for transfer of variables:
export, get.indexed.var, get.var, import, put.indexed.var, put.var

I use them to transfer information from a main session to a zoom display sub-session in order to supply the query.extension (where clause) an appropriate filter based on different data choices that a user may enter.


Gilbert Guymer
Lufkin Industries, Inc.

rosalbaperez
8th July 2003, 22:45
Thanks for all your help NPRao & gguymer!

I was able to use the expr.compile function to create the name of the field and then retrieve the value with s.expr$(). So, I have 5 fields on a table and I am able to display the value of all 5 fields in this loop.

For i = 1 to 5
expr_id = expr.compile("psrad080.astat"&str$(i))
message("value of field astat = %s",s.expr$(expr_id))
EndFor

Thanks
Rosalba

estotz
8th July 2003, 23:54
You can also use DYNAMIC SQL to read a table using applicable code ....

use functions SQL.PARSE, SQL.EXEC, SQL.FETCH, SQL.BREAK etc.

Look at database handling in the online help. It's great for querying tables and fields where the table or field is not known till run time, or if you want to get really fancy in a program script.

Eric