frenny
10th September 2016, 09:06
Hello ,
i am unable to get value of variable using import/export.
here this is just sample code.

session1 -
f.wloc = "BUL"
export("f.wloc", f.wloc)

session2-
import("f.wloc", f.wloc)

i have declare my variable "f.wloc" as extern in both session
but when i am trying to get value of that variable using import statement it will give me blank value.
It is extern variable so before import statement value for that variable is exist but after import statement value is overwrite with blank.
i have use many import export statement before with same condition and it is working fine but i have found this case recently. i am trying to get value of import variable with different name . but that is also not working.

why that value is overwrite in this case.is session property is responsible for this?

Thank you
Frenny

bhushanchanda
12th September 2016, 19:44
Hi,

Have you tried using get.var()

before.program:

get.var( parent, "f.wloc", f.wloc )

frenny
13th September 2016, 08:38
hello sir,
i have also tried this but it is not working.

srprks
13th September 2016, 10:14
If its a table field then you can go for importing table fields. because table fields are global variable :) :D

bhushanchanda
13th September 2016, 11:15
Hi,

Usually, I just use an import in the called session script and it works just fine. Can you please post some piece of code from both the session i.e. calling and called showing the part where you are importing and calling the other session?

frenny
13th September 2016, 15:03
Hello sir,
This is my code.

session 1 - session which is zoomed from session 2
choice.end.program:
before.choice:
f.wloc = whinr140.loca
f.idat = whinr140.idat
export("f.wloc", f.wloc)
export("f.idat", f.idat)

session2- Main Session

field.ltsfc652.clot:
before.zoom:
whinr140.cwar = i.cwar
whinr140.item = i.item

after.zoom:
if isspace(f.wloc) then
import("f.wloc", f.wloc)
import("f.idat", f.idat)
endif

ltsfc652.loca = f.wloc
ltsfc652.idat = f.idat
display("ltsfc652.loca")
display("ltsfc652.idat")

here i have put isspace condition in after zoom because before import statement, value is present in that variable. but after import it will be blank.
Session 1 is zoomed from many other session with similar condition ,but only in few case it will return blank value using import statement.

Thank you.

bhushanchanda
13th September 2016, 15:42
Hi,

You might try couple of things here -

1. Declare table whinr140 in your Calling session(session 2)
2. Check in debugger, if the value of fields whinr140.loca and whinr140.idat are retained. They should be.

Now you can use them directly instead of variables.

The above case can be used if you don't have any conditions written for setting the variable.

If you are setting the 2 variables based on some conditions then you might try using the following solutions -

1. Check this link (http://www.baanboard.com/baanboard/showthread.php?t=8394)

2. Instead of choice.end.program, you might try using the following section -

zoom.from.all:
on.exit:

So, your code should look something like this -

session 1 - session which is zoomed from session 2
zoom.from.all:
on.exit:
f.wloc = whinr140.loca
f.idat = whinr140.idat

session2- Main Session

field.ltsfc652.clot:
before.zoom:
whinr140.cwar = i.cwar
whinr140.item = i.item

after.zoom:
if isspace(f.wloc) then
import("f.wloc", f.wloc)
import("f.idat", f.idat)
endif

ltsfc652.loca = f.wloc
ltsfc652.idat = f.idat
display("ltsfc652.loca")
display("ltsfc652.idat")

frenny
14th September 2016, 08:26
Hello bhushan sir,

i have tried both solution using table field and also using zoom section but still it is not working. i have many temporary solution but i just want to find why this is not working.

Thank you

andreas.toepper
14th September 2016, 09:40
here i have put isspace condition in after zoom because before import statement, value is present in that variable. but after import it will be blank.
i just want to find why this is not working.

I think that's because of how import(..) works. It is stated in the reference guide, that it is basically equivalent to get.var( parent, "variable", value).

So import(..) will try to read the value of a parent session. If there is no parent present, I think it will empty the imported variables.