DEF ENV and BEGIN

Started by James Zukowski, April 23, 2026, 01:25:12 PM

Previous topic - Next topic

James Zukowski

We're looking at the DEF ENV directive to set some things up as we start our application. Doing some very preliminary tests, it seems as though the BEGIN directive clears out anything that had been set. I thought this was setting the Windows Environment variables for the session, which I would think would be session-permanent.
Is BEGIN supposed to clear these out?
James Zukowski
Sr. Developer - J&E

BRAND>SAFWAY
Brand Industrial Services

James Zukowski

James Zukowski
Sr. Developer - J&E

BRAND>SAFWAY
Brand Industrial Services

Devon Austen

I just tried it and the begin directive does not clear the env vars set via def env() in my test

->def env("pxplus_var")="Hello"
->?env("pxplus_var")
Hello
->begin
->?env("pxplus_var")
Hello

Looking at the code I can also confirm it can't.

Maybe something else is happening that is starting a new process?
Principal Software Engineer for PVX Plus Technologies LTD.

James Zukowski

#3
Could it be a difference between Linux-based and Windows-based systems? I attached what I got with your test.
James Zukowski
Sr. Developer - J&E

BRAND>SAFWAY
Brand Industrial Services

Devon Austen

I just tried locally from Windows and Linux and then via WindX to a Windows and Linux server. All maintained the env var after the begin.

I was testing in PxPlus 2025 Update 1.

What version are you running?
Principal Software Engineer for PVX Plus Technologies LTD.

James Zukowski

Tested using v22.00.0002

We'll be updating to 22.01 shortly.
James Zukowski
Sr. Developer - J&E

BRAND>SAFWAY
Brand Industrial Services

Devon Austen

I just tested in that version via local/windx and win/linux and it never clears it either.

Do you have something in your START_UP that could be causing issues?

From our side we are calling a OS system call to set the env var and only ever call that when DEF ENV() is used. The only way to unset it is to call DEF ENV() again for the same name and with no value. That or close the process.

Maybe some how your system is closing the process?
Principal Software Engineer for PVX Plus Technologies LTD.

James Zukowski

The screen snip I included is exactly the process I went through. There were no other actions between the steps. This is being launched out of Connection Manager. The v22.01 version should be installed in the next couple of days, so I'll re-test it when it gets here.
James Zukowski
Sr. Developer - J&E

BRAND>SAFWAY
Brand Industrial Services

Devon Austen

The code didn't change for this between those versions and I tested with version 22.00.0002 here and the begin did not clear env vars for me.

This means likely there is something in your START_UP or INI file that is different between your test and mine.

What WindX type are you using Simple CS? What host OS are you using?
Principal Software Engineer for PVX Plus Technologies LTD.

James Zukowski

These parameters are set in START_UP and our lead program sequence:

SET_PARAM 'KF'=2
SET_PARAM '+A'=12
SET_PARAM 'BY'=0
SET_PARAM -'D0'
SET_PARAM 'FF'=3
SET_PARAM 'OP'
SET_PARAM 'XT'=0
SET_PARAM 'F,'
SET_PARAM 'XF'
SET_PARAM 'NE'
SET_PARAM '+M'
SET_PARAM -'SB'

SET_PARAM 'PQ'=PRM('PQ')

EXECUTE "[WDX]SET_PARAM 'TC'=3"
SET_PARAM 'TC'=3

There is no server-side pxplus.ini in use. The Windows-side pxplus.ini file contains:

[Font]
Points=19
Charset=0
Name=Lucida Console
[WindowFrame]
TypeSizeLoc=1,902,594,200,131

After exiting to command mode, I entered the statements shown in the previous example.

The PxPlus version has been upgraded to 22.01 and it still produces the same results.

The server is running RHEL 9.7
Client is Windows 11 Enterprise 10.0.26100 Build 26100

Many aspects of the PC are managed by the company. Would there be any restrictions on this behavior coming from there? Would there be any sort of "memory protection" prohibiting this?
James Zukowski
Sr. Developer - J&E

BRAND>SAFWAY
Brand Industrial Services

Devon Austen

I was able to reproduce the issue on a RHEL9 pxplus running locally (i.e. no windx).

With that I was able to find and fix the issue. The issue only affected linux/unix.

PxPlus 2026 should include the fix.
Principal Software Engineer for PVX Plus Technologies LTD.