Please enable JavaScript to view this site.

A-Shell Programmer’s Notepad

Navigation: Miscellaneous Notes

Determining Current Project

Scroll Prev Top Next More

The PYPN API does not seem to offer this information (yet). But here is a workaround. APN now creates a file %TEMP%\curproj.lst whenever you open a project group, and updates it whenever you open a project or set a project as the active one. The contents of the file looks like:

ProjGroupFile=C:\vm\APNtest3\projects\Test Project Group.ppg

ProjFile=c:\vm\APNtest3\test proj1.pnproj,{E5D45580-F351-11E3-3D6C-07E3C48F4AE2}

ProjFile=c:\vm\APNtest3\test proj2.pnproj,{E5D45580-F351-11E3-3D6C-07E3C48F4AE3}

 

The first line identifies the Project Group File. After that are one or more ProjFile lines corresponding to projects opened within the group. Since only one project can be active at a time, the last of these lines is probably the only one you care about. (Each time there is a change to the active project, a new line will be appended to the file. The file is reset at the start of an APN session.)

The ProjFile line contains the project file (.pnproj) spec, and optionally, the GUID of the project’s template. (Projects do not have to be based on templates; if not, there will be no {...} GUID on the line.)

You can use the GUID to cross reference with the APN\settings\UserTools.xml file which contains the global/scheme and project-specific tool definitions. For example, here’s a UserTools.xml with one global ASB Compile option and two project-template-specific ones:

<schemetools>

<scheme name="asb">

<tool command="%(APN)\compil.exe" flags="61" folder="%d" index="0" name="ASB Compile" params="-ini c:\vm\miame\miame.ini -w:2000 -x:2 -m -so &quot;%d%f&quot;" parsepattern="%f,%l," shortcut="116">

</tool>

</scheme>

<scheme name="python">

<tool command="c:\Python27\python.exe" flags="105" folder="%d" index="0" name="Run Python" params="%f" parsepattern="" shortcut="561">

</tool>

</scheme>

<project projectid="{E5D45580-F351-11E3-3D6C-07E3C48F4AE2}">

<tool command="%(APN)\compil.exe" flags="317" folder="%d" index="0" name="Compile (proj1)" params="-ini c:\vm\miame\miame.ini -m -so -x:2 &quot;%d%f&quot;" parsepattern="%f,%l," shortcut="117">

</tool>

</project>

<project projectid="{E5D45580-F351-11E3-3D6C-07E3C48F4AE3}">

<tool command="%(APN)\compil.exe" flags="317" folder="%d" index="0" name="Compil (proj2)" params="-ini c:\vm\miame\miame.ini -m -so -x:2 &quot;%d%f&quot;" parsepattern="%f,%l" shortcut="117">

</tool>

</project>

</schemetools>