simona
12th May 2015, 12:15
Hello,

How can I get the local environment variables???
I need to write a file on local machine of the user, preferable in TEMP (or TMP) local environment variable. How can I get the valuo of this env var?
Thank you!!
Sim

bhushanchanda
12th May 2015, 12:54
Hi,

You can use ${..} syntax to do that.

Check these 2 threads -

Thread 1 (http://www.baanboard.com/baanboard/showthread.php?p=32146)

Thread 2 (http://www.baanboard.com/baanboard/showthread.php?s=&threadid=7329&highlight=client+variables)

simona
12th May 2015, 13:53
x = server2client(bse.dir$() & "nbr.xml", "${TEMP}\nbr.xml", false)
Thanks, Bhushan!! :D

simona
29th May 2015, 12:52
In this line, the ${TEMP} var is successfully used.
x=server2client("bse.tmp.dir$()/bnr.xml", "${TEMP}/bnr.xml", false)

BUT how can I get the value of ${TEMP} to be able to find the local file??!
message ("File created %s.", "${TEMP}/bnr.xml") is displayed as it is :(

thanks!
Sim

bhushanchanda
29th May 2015, 13:16
Hi,

Did you tried something like this -

string filename(1024),buffer(1024)
long lret
long fp
long fsize
long leng
filename = "C:\checkenv_" & str$(random()) & ".out"
start.application.local("cmd /c echo %temp%" & " > " & filename, true, lret)
fp = seq.open.local(filename, "rt", 1)
if fp > 0 then
e = seq.read.local(buffer, fsize, fp)
endif
seq.close.local(fp)
leng = len(buffer)
buffer = buffer(1;leng-1)
buffer = trim$(buffer) & "\bnr.xml"
message("File created successfully at %s", buffer)

Make sure there are write permissions to C drive.

Reference (http://www.baanboard.com/baanboard/showthread.php?t=57703)

Also, if you are on Latest Porting set, you can try this -


declaration:
#include <bic_desktop>

function main()
{
string filename(200)
filename = get.client.directory("${TEMP}")
filename = trim$(filename) & "\bnr.xml"
message("File created successfully at %s", trim$(filename))
}