Author Topic: Workspace environment: Add to existing variable  (Read 980 times)

stzari

  • Community Member
  • Posts: 33
  • Hero Points: 8
Workspace environment: Add to existing variable
« on: May 11, 2020, 03:01:24 PM »
Hi,

is there a possibility to append workspace specific data to an existing environment variable (e.g. to the PATH) only once?

I found the following topics
https://community.slickedit.com/index.php?topic=4952
https://community.slickedit.com/index.php?topic=5194
and added the following command to the workspace environment:

Set PATH=%xe%(PATH):/another_path/

This works as expected, but is executed every time I switch workspaces, so /another_path/ gets appended multiple times.
Is there any way to avoid this (other than closing and reopening SE whenever I switch the current workspace)?

Thanks in advance
  Stamatis

(VS 24.0.2.5 Pro on Linux, Leap15.1)

Graeme

  • Senior Community Member
  • Posts: 2793
  • Hero Points: 347
Re: Workspace environment: Add to existing variable
« Reply #1 on: May 12, 2020, 10:09:25 AM »
You can use the pos function to see if the path already has that workspace path
from the help
int pos(_str needle, _str haystack="", int start=1, _str options="", _str wordchars=null);

if (pos(another_path, get_env("PATH")) == 0)
{
   set_env(...);
}