Author Topic: Workspace Environment variable expanded in Project vpj Files ...  (Read 5764 times)

ehab

  • Senior Community Member
  • Posts: 285
  • Hero Points: 15
  • coding with SE is like playing music
Workspace Environment variable expanded in Project vpj Files ...
« on: September 20, 2012, 11:51:05 AM »
hi

i set up my vpw file as follows

Code: [Select]
<!DOCTYPE Workspace SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpw.dtd">
<Workspace Version="10.0" VendorName="SlickEdit">
<Projects>
<Project File="Generic.vpj"/>
</Projects>
<Environment>
<Set Name="ProjectPath" Value="/home/ehab/Projects/mytestdir"/>
</Environment>
</Workspace>

then in my Generic.vpj

Code: [Select]
<!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd">
<Project
<!-- a log of stuff omitted here -->
<Files>
<F
N="%(ProjectPath)/*.*"
Recurse="1"
Refilter="0"
Excludes="*.gz;*/.osc/;*.git/;"/>
</Files>
</Project>

when i open the workspace i expect all files under /home/ehab/Projects/mytestdir to be populated.  Hard coding the path is fine.

Does anybody know how to reuse a env var in workspace file to be extended in the project file?

any hints would be appreciated.

thanks
« Last Edit: September 20, 2012, 04:58:13 PM by ehab »

Graeme

  • Senior Community Member
  • Posts: 2796
  • Hero Points: 347
Re: Workspace Environment variable expanded in Project vpj Files ...
« Reply #1 on: September 21, 2012, 02:21:31 PM »
Not sure I'm following exactly what you're doing here.  If you change F N="%(ProjectPath)/*.*" to something like
F N="C:/TEMP/*.*"
then does whatever you're trying to do, work?  If you open project properties, what do you see on the files tab?

Quote
when i open the workspace i expect all files under /home/ehab/Projects/mytestdir to be populated.

Populated where?  In the project properties dialog?

ehab

  • Senior Community Member
  • Posts: 285
  • Hero Points: 15
  • coding with SE is like playing music
Re: Workspace Environment variable expanded in Project vpj Files ...
« Reply #2 on: September 21, 2012, 02:43:52 PM »
hi Graeme, long time no speak, hope you and all the family doing well  :) , autumn here in Finland and getting chilly all is good from myside thank god.

well, if i change the N to a physical path e.g c:/TEMP/*.* then it lists the files and i can work from there, i can also see the files.

i think that part is not expanded internally in SE, now i am looking at project.e and others, nothing getting anywhere thou.

thanks for any attempts from your side.

Graeme

  • Senior Community Member
  • Posts: 2796
  • Hero Points: 347
Re: Workspace Environment variable expanded in Project vpj Files ...
« Reply #3 on: September 21, 2012, 02:50:03 PM »
Hi Ehab

I'm definitely not following.
Quote
well, if i change the N to a physical path e.g c:/TEMP/*.* then it lists the files

What do you mean "it lists the files" ?  Where do you see a list of the files?

Also, try to answer the questions in my previous post... :)

ehab

  • Senior Community Member
  • Posts: 285
  • Hero Points: 15
  • coding with SE is like playing music
Re: Workspace Environment variable expanded in Project vpj Files ...
« Reply #4 on: September 21, 2012, 03:13:27 PM »
ok, i'll try to explain better.

my main target is to have a project recursively add all files and folders under the path specified in the environment variable.

for example, my code lives in c:\projects\test1\

Code: [Select]
<F
N="c:\projects\test1\*.*"
Recurse="1"
Refilter="0"
Excludes="*.gz;*/.osc/;"/>

then the project tree " activate-projects " will be populated and i can work on them.

if i substitute

Code: [Select]
<F
N="%(ProjectPath)\*.*"
Recurse="1"
Refilter="0"
Excludes="*.gz;*/.osc/;"/>

%(ProjectsDir) is defined in the workspace environment variable as

Code: [Select]
<Environment>
<Set Name="ProjectPath" Value="c:\projects\test1"/>
</Environment>

the ProjectPath can be read "expanded" fine if i place it in for example:

RunFromDir="%(ProjectPath)"

but not from  the N=" " tag.

so i am thinking when reading the N tag the value is taken literally and not expanded.

I do not want it populated in project properties dialog but i want to see it in the project tree form that can be seen if you do a "activate-projects" cmd.

did i make any sense?



Graeme

  • Senior Community Member
  • Posts: 2796
  • Hero Points: 347
Re: Workspace Environment variable expanded in Project vpj Files ...
« Reply #5 on: September 21, 2012, 03:45:57 PM »
Quote
did i make any sense?
Hmm, ok, sort of :)

So are you creating a generic project template that has the %(ProjectPath) thing?  If so, when you create an actual project from the project template, can you change %(ProjectPath) to a "hard coded" path when you first create the project or when a project is opened.

It looks like _getProjectFiles and _FileListAddFilesInProject etc. are in the slickedit core rather than in Slick C.

There is this
      call_list('_prjopen_');
and this
   call_list('_workspace_opened_');

which means you can write _prjopen_do_something() macro and it will get called when a project is opened but it's probably a bit late to change the project file at that stage.

Gered

  • Community Member
  • Posts: 27
  • Hero Points: 1
Re: Workspace Environment variable expanded in Project vpj Files ...
« Reply #6 on: September 21, 2012, 04:49:44 PM »
Let me first say, ehab, you have made my day by posting this. I had no idea that you could do this with SlickEdit project files. Very convenient!

Anyway, I didn't have much luck with using environment variables either (also tried %rp for referring to the project path, same thing as ProjectPath in that it wasn't expanded either).

However, I thought of something else that seems to work well for me. My project directory is structured like this:

Code: [Select]
project_root/
|
|--- project.vpw
|--- project.vpj
|--- src/                (contains *.cpp, *.c, *.h organized in sub dirs)
|--- lib/                (contains sub dirs for other open source *.c/*.cpp/*.h libraries I'm using)

So, I put the following in my .vpj:

Code: [Select]
<Files AutoFolders="DirectoryView">
<F
N="./src/*.*"
Recurse="1"
Refilter="0"/>
<F
N="./lib/*.*"
Recurse="1"
Refilter="0"/>
</Files>

Which appears to work fine as the current directory "./" appears to be based on where the vpj (or maybe the vpw?) is.

Maybe something like that might work for you? Would be nice either way for environment variables to work here though eventually. :)

ehab

  • Senior Community Member
  • Posts: 285
  • Hero Points: 15
  • coding with SE is like playing music
Re: Workspace Environment variable expanded in Project vpj Files ...
« Reply #7 on: September 21, 2012, 05:08:47 PM »
@Graeme , somehow i think the N element is read before what you mentioned and it can be just passing a expandFelement(Nvalue).  If nothing comes, I will ask support something like this:

Can a workspace environment variable located in vpw file a be expanded in the project file at N="%(varname)" element during project loading? if yes how, if not then ask for feature/fix or i can live changing 2 files.

@Gered nice, i didn't think i can have multiple F elements, for sure comes handy. Lets see if support can add/fix this : )


Gered

  • Community Member
  • Posts: 27
  • Hero Points: 1
Re: Workspace Environment variable expanded in Project vpj Files ...
« Reply #8 on: September 21, 2012, 05:13:45 PM »
Well, I was more pointing out that you could possibly use "./" instead of "%(ProjectPath)" as a temporary solution depending on how your project files are structured. :P But either way, glad you at least found using multiple F elements handy, heh.