Tapatalk

Using configured project path in user/project tools

Using configured project path in user/project tools

5
NewbieNewbie
5

    Mar 20, 2012#1

    Hello all,

    either I'm doing something wrong or misinterpreting the help file, so decided to ask here in case someone else has already figured out the correct answer:

    I have a folder where all project files are saved (c:\ueprojects\project1.prj etc), and actual project1 contains source files from c:\project1\ folder ('c:\project1' is specified as the project directory in project1.prj).

    I'm creating a tool that needs to be aware of which project (which folder) it is run from, so I try to use %RP parameter to read the project path, expecting to get 'c:\project1', but instead it gives me the folder where prj files themselves are stored (c:\ueprojects)...

    Is this the intended behavior? And if is, is there any other way (other than opening the project1.prj file and searching in it for the project path) to get the path for the current project?

    Thanks for all the advice.
    zura

    6,685587
    Grand MasterGrand Master
    6,685587

      Mar 20, 2012#2

      Indeed, the help page Tool Configuration command is not clear enough at the moment regarding the information you need. %RP (short 8.3 format) respectively %rp (long format) is a placeholder for path of the project file *.prj. It can be seen just indirectly because of %r (full file name with path) and %rn (just file name) which would not make sense if the configured project directory would be referenced with %rp.

      There is no variable for the configured project directory. You might send a feature request email to IDM support asking for a variable referencing the configured project directory.

      If all your projects are subdirectories in the same parent directory and the project file name is equal the project directory name, you may easily build the project directory path by using the project file name.

      Another solution would be to extract the configured project directory path from the *.prj file. This can be done by configuring a batch file as user/project tool with "%r" or %R containing following lines:

      Code: Select all

      @echo off
      for /f "usebackq eol=[ tokens=1,2 delims==" %%A in (%1) do (
       if "%%A"=="Project Directory" (
        set ProjPath=%%B
        goto !FoundProjPath
       )
      )
      :!FoundProjPath
      This little code searches in the file with file name passed to the batch file as first parameter line by line for the string Project Directory followed by an equal sign and a string value assigned to environment variable ProjPath. The for loop is exited when project directory entry in the project file was found. Lines starting with [ are skipped to make the find for the really wanted value a little bit faster.

      2362
      MasterMaster
      2362

        Mar 20, 2012#3

        I just happened to hit this same speed bump.

        Since you are already creating a user tool, might I suggest you go ahead and pass the project file name (%r) to this tool, and program the tool to take in this project file and locate the project path from the project file, as it would be faster than the batch file.

        Either way, it's an awkward workaround. I, personally, like to keep one path for all my project files in one neat location, then my project folders might be in a number of different locations, depending on whether I'm coding for a website (each site has to have a different physical location for the web server), coding a desktop application (which I don't want to be in the web server path), etc.

        It's easier to keep project files in one location, since I generally don't have more than 20 projects at once, and since it is easier to open a project when I don't have to "browse" around to remember where I put it!

        I'll also send in a feature request for this.

        5
        NewbieNewbie
        5

          Mar 20, 2012#4

          good, so I'm not completely crazy to think that it was not trivial :)
          I needed this to call an external program with a specific file from the active project, so I guess the easiest would be to pass the project file name as a parameter and parse all folder paths outside.

          Thanks for the responses!

          2362
          MasterMaster
          2362

            Mar 21, 2012#5

            I sent a feature request to IDM, and got back the following reply:
            Thank you for your message. I understand the dilemma here and agree with your feedback. We will consider changing this or making an additional parameter available for user tools to reference the path to the actual project directory shown in the project settings dialog.