You are here: PSPad forum > English discussion forum > How to use environment variables / project root in project files?

How to use environment variables / project root in project files?

#1 How to use environment variables / project root in project files?

Posted by: human | Date: 2017-04-10 11:26 | IP: IP Logged

A project exists in different locations, therefore I'd like to use system environment variables, first of all %USERNAME% in "Project -> New from directory".

Question: Is it possible already to use %ProjectDir% in the project's configuration?

In general: it would be nice to be able to define variables in the project configuration, for example "includedir1" to "X:\inc" and use "%includedir1%" in the project file instead of "X:\inc" in all places (the reason: placing the project file in VCS with local [different] paths) would show only one (local) change, not a change in all of the include lines.

Options: Reply | Quote | Up ^


#2 Re: How to use environment variables / project root in project files?

Posted by: pspad | Date: 2017-04-10 11:41 | IP: IP Logged

human:
A project exists in different locations, therefore I'd like to use system environment variables, first of all %USERNAME% in "Project -> New from directory".

Question: Is it possible already to use %ProjectDir% in the project's configuration?

In general: it would be nice to be able to define variables in the project configuration, for example "includedir1" to "X:\inc" and use "%includedir1%" in the project file instead of "X:\inc" in all places (the reason: placing the project file in VCS with local [different] paths) would show only one (local) change, not a change in all of the include lines.

Are you sure with %UserName%? Didn't you mean %UserProfile%?
If project settings is configured to contains relative path, files are stored as relative to project file. In this case Project is easy to move. Condition: project file must be placed with project files, e.g. project folder root.

No, just no isn't possible to use variables in project folder
I want to move project file into XML to be able easy expand it. After this step we can add project variables e.t.c.

Options: Reply | Quote | Up ^


#3 Re: How to use environment variables / project root in project files?

Posted by: human | Date: 2017-04-10 13:04 | IP: IP Logged

Yes, I meant %USERNAME%, it would be part of X:\%USERNAME% where X is a mapped network drive smiling smiley

But this can wait until the xml based projects, just wanted to ask before putting more time into the question why this doesn't work.

The problem with the "not relative" paths got in by importing from X:\username\project1_src (the project file contains the files under this directory fine) and later adding X:\includes (which is used by multiple projects). All files under X:\includes have their full path in the project file. To support relative paths here, too PSPad would need to check and use "..\" to go up higher than the project's main directory.

Options: Reply | Quote | Up ^


#4 Re: How to use environment variables / project root in project files?

Posted by: pspad | Date: 2017-04-10 13:29 | IP: IP Logged

If project is stored on X: drive and project option doesn't contains checked
[x]Absolute paths for files,
PSPad will store files with relative path to project file

Options: Reply | Quote | Up ^


#5 Re: How to use environment variables / project root in project files?

Posted by: human | Date: 2017-04-10 14:49 | IP: IP Logged

pspad:
If project is stored on X: drive and project option doesn't contains checked
[x]Absolute paths for files,
PSPad will store files with relative path to project file

Sounds good, I assume "will" means in the future. Just rechecked:

* Project -> create from directory X:\src\test\test1 --> all in
* Project Settings: "Absolute paths for files" is unchecked
* created new folder "test" in project explorer
* used Add Files... on this folder, chose ten files in X:\includes\test\test1
* saved project

part of the result:

[Project tree]
test
+test
X:\includes\test\test1\FIRST.CPY
X:\includes\test\test1\SECOND.CPY
-i8
X:\src\test\test1\SOME.CPY
X:\src\test\test1\OTHER.CPY

Options: Reply | Quote | Up ^


#6 Re: How to use environment variables / project root in project files?

Posted by: pspad | Date: 2017-04-10 14:53 | IP: IP Logged

Where is the main project file? It's saved in X: folder before you start project from folder? If not, how can PSPad store relative paths when main project file has no path?

Options: Reply | Quote | Up ^


#7 Re: How to use environment variables / project root in project files?

Posted by: human | Date: 2017-04-10 15:01 | IP: IP Logged

... I see, I just saved the project file in %USERPROFILE%\Desktop\test.ppr, retesting with saving it in X:\src\test leads to

[Project tree]
+test
..\..\..\..\includes\test\test1\FIRST.CPY
..\..\..\..\includes\test\test1\SECOND.CPY
-Root
test1\SOME.CPY
test1\OTHER.CPY

this one is fine.
Last test with UNC-paths:

\\SERVER\share\src\test\test1
\\SERVER\share2\includes\test\test1
project file in \\SERVER\share\src\test

[Project tree]
+test
\\SERVER\share2\includes\test\test1\FIRST.CPY
\\SERVER\share2\includes\test\test1\SECOND.CPY
-Root
test1\SOME.CPY
test1\OTHER.CPY

It may be possible to tweak relative paths in this case, too.

Options: Reply | Quote | Up ^






Editor PSPad - freeware editor, © 2001 - 2024 Jan Fiala, Hosted by Webhosting TOJEONO.CZ, design by WebDesign PAY & SOFT, code Petr Dvořák, Privacy policy and GDPR