Skip to main content
Question

File operation with replacement of environment variable

  • February 24, 2026
  • 7 replies
  • 89 views

Ingo Stiller
Forum|alt.badge.img+3

We do all our exports to CSV by lfieldump and this works for years

Now, however, a customer came up with the idea of using a DOS environment variable to determine the directory instead of fixed directories.
So instead of "Q:\outpute\export1.csv,"
it should now be "%app_export%\export1.csv"
(where app_export is defined differently on each client).
Unfortunately, Uniface cannot handle this; the file system converts it to "?app_export?\export1.csv," and the file system complains.
Is there a simple solution for this, i.e., any letter combinations that can be used at the file system level to resolve "%%app_export%"?

Of course, I can use a few tricks to ask Windows/DOS what the resolution is before each fieldump, and then replace that part. 
But I'm reluctant to check all our programs for this and make changes :-)

A customer 

7 replies

Iain Sharp
Forum|alt.badge.img+5
  • Inspiring
  • February 24, 2026

So an example from my asn files is 

ide_state.zip    \\server\States_%%($USERNAME)\develide_state.zip

Where %%($USERNAME) extrapolates to the environment variable %USERNAME%. 

Not sure where the original pathname you are using is coming from in the code, but if you can global replace with something, you can replace with $logical, and then use the substitution on the asn file. 

This is 10.4, I think it was enabled 10.3…. 

Regards, 

Iain
 


Gianni Sandigliano
Forum|alt.badge.img+3

Hi Ingo,

Your current expectation is that Windows (NON Uniface!) convert %app_export% to the equivalent environment value; unfortunately this variable substitution is NOT system wide but it is explicitly built into cmd.exe, like it was in command.com before, in older Windows versions.

I feel in Uniface you should use $settings() function to collect that environment variable… something like:
“%%$setting ("", "APP_EXPORT", "ENVDATA")%%%\export1.csv”.

Hope it helps…

Regards,
Gianni

 


Juliano Anoar Haoach Garcia
Forum|alt.badge.img+1

Hi Ingo,

Your current expectation is that Windows (NON Uniface!) convert %app_export% to the equivalent environment value; unfortunately this variable substitution is NOT system wide but it is explicitly built into cmd.exe, like it was in command.com before, in older Windows versions.

I feel in Uniface you should use $settings() function to collect that environment variable… something like:
“%%$setting ("", "APP_EXPORT", "ENVDATA")%%%\export1.csv”.

Hope it helps…

Regards,
Gianni

 

That's right


OsmanShariff
Forum|alt.badge.img+3
  • Participating Frequently
  • March 2, 2026

If you do not currently have the uniface version that allows (Using Expressions in Assignment Files), then you can pass the environment variable into uniface at the end of your command line that runs your application.

C:\Uniface\common\bin\uniface.exe /asn=my.asn /ini=my.ini MYAPP %app_export%

and pick it up with $1 in the .aps

 

I think that can work

 

 


Ingo Stiller
Forum|alt.badge.img+3
  • Author
  • Participating Frequently
  • March 2, 2026

Thank for all your sugestions.
My main problem is not to get the susbstituation of an environment varible like “sharepoint”. This can be done by $setting(xyz)
But I have to replace all file-function by “replace and then filefunction”
Before
   lfiledump v_FIELNAME,v_CIONTENT
After (if I’m sure there is onl “sharepoint” and no other environment variable)
   v_OLD=”sharepoint” 
   v_NEW=$setting ("", v_OLD, "ENVDATA")
v_FILENAME = $replace(v_FILENAME,1,$concat(“%”,v_OLD,”%”),
$concat(“%”,v_NEW,”%”),-1)
   lfiledump v_FIELNAME,v_CIONTENT
This also not the problem for one occurence, but I have to find all file-functions and do this replacment.
Or I have to set the v_FILENAME at the begin of the export and then call all file-functions with this new filename.
But for this I have to be sure, thet filename only set at one point im code and only this new filename is used in all of the depending proc-code (components,global proc,...)

Let’s see what our customer says in a next round, if it realy need %sharepont%
Or how much he will pay :-)


OsmanShariff
Forum|alt.badge.img+3
  • Participating Frequently
  • March 2, 2026

How about export to xml all the objects that use 

lfiledump v_FIELNAME,v_CIONTENT

 

Use z.b notepad++ regex function find/replace

find: (lfiledump v_FIELNAME,v_CIONTENT)

replace: call G_CONVERT\(v_FIELNAME\)\n\1

 

The result is your code will look like this 

call G_CONVERT(v_FIELNAME)
lfiledump v_FIELNAME,v_CIONTENT

 

Then just put what you want in global proc with in/out v_FIELNAME param.

 


Ingo Stiller
Forum|alt.badge.img+3
  • Author
  • Participating Frequently
  • March 3, 2026

Hi Osman
If the real life would be so easy :-)
the variable changes from component to component.
And it is not only lfiledump but also other functions like $lfileexists ,$lfileproperties,...