hpng98
31st December 2002, 03:23
Hi.
I have read program script which contain the code as below:

162 zoom.from.choice:
163 on.entry:
164 import("zoomed.from", zoomed.from)
165 if zoomed.from then
166 import.default.values()
167 else
168 import("tccom010.cuno", cuno.f)
169 import("tccom010.cuno", cuno.t)
170 endif

890 function import.default.values()
891 {
892 import("ncmp.f", ncmp.f)
893 import("ncmp.t", ncmp.t)
894 import("ccty.f", ccty.f)
895 import("ccty.t", ccty.t)
896 import("creg.f", creg.t)
897 import("creg.t", creg.t)
898 import("ficu.f", ficu.f)


but myself totally can't get wht it meant.
1. it import the data from which table? how do I know?
2. wht is the value for "zoomed.from" ?
3. is tht anyone can give me some explaination abt the code?

Thanks alot.

morpheus
31st December 2002, 07:12
1. it import the data from which table? how do I know?

import() does not import data from any table. It imports the value of one variable into other.

2. wht is the value for "zoomed.from" ?

zoomed.from, here is a boolean. Value is either True or False. (IF condition used).

3. is tht anyone can give me some explaination abt the code?

When the session is zoomed, the boolean value is imported into that session. If the value is True, the the function is called. This function also importing the values.

Hope this is clear.

hpng98
31st December 2002, 10:50
but from where the system get the value for : -

892 import("ncmp.f", ncmp.f)
893 import("ncmp.t", ncmp.t)
894 import("ccty.f", ccty.f)
895 import("ccty.t", ccty.t)
896 import("creg.f", creg.t)
897 import("creg.t", creg.t)
898 import("ficu.f", ficu.f)
899 import("ficu.t", ficu.t)
900 import("cuno.f", cuno.f)
901 import("cuno.t", cuno.t)
902 import("seak.f", seak.f)

etc.
my form got no these field...

Thanks.

OmeLuuk
31st December 2002, 11:44
If you run the script in debugger, do you see these variables having a value? It may be that the caller process filled these variables (so the parent session calling this session). If not filled, then these statements do nothing, because all they do is fill a variable with a void value...

morpheus
31st December 2002, 16:06
Going by the nomenclature of the variables, it seems that they are form variables. In that case the inputs made by the user are imported to the called session.
Other possibility is that, some SELECT statement is fired, and the selected values are stored in these variables, or these variables are the calculated ones, which ultimately are being imported.

OmeLuuk
31st December 2002, 16:13
morpheus: Going by the nomenclature of the variables, it seems that they are form variables.Indeed, but...hpng98: my form got no these field...

KlayVessel
2nd January 2003, 07:32
I have seen a lot of developers confused about how to use import and export functions. Part of this is due to how it's use has been explained (help text and Baan classes, at least in the distance past; don't know about recent years).

Simply put, import() is a wrapper function around get.var(). These retrieve values of extern variables from another process's (within the bshell VM) address space and set the local variable to the value retrieved. Note that import() always operates on the parent process, whereas get.var() can be used to specify the process (even the same one using the import). In all cases these variables must be declared as "extern" in the referenced process -- if they are not declared this way or do not exist, the net effect is the same...the local variable is left unchanged (I believe, it could be reset to null).

export() and put.var() are the inverse and store the contents of a local variable in an "extern" variable in another process. Like import(), export() always operates on the parent.

The confusion often comes when a developer thinks he should put the export/import in the parent process rather than the child.

To answer this specific question posed in this thread. The variable names referenced must be in the parent process of the session where your example code is located. If not, then that is why there are no values showing up in the fields on the child session/form.

Note: The first parameter to import is a string. There is absolutely no required correlation between the name used there and the name of the local variable. That is the parent variable name and child variable name can be different.