Author Topic: How to convert a relative path to an absolute one  (Read 423 times)

timur

  • Senior Community Member
  • Posts: 202
  • Hero Points: 3
How to convert a relative path to an absolute one
« on: May 08, 2023, 10:13:53 PM »
I have this macro that I wrote for changing the current directory to the project working directory:

Code: [Select]
_command cdp() name_info(','VSARG2_CMDLINE)
{
   cd('+p +a ' :+ _ProjectGet_WorkingDir(_ProjectHandle()))
}

The problem is that this frequently fails because _ProjectGet_WorkingDir() returns a path that is relative to the location of the .vpw file.  How can I convert this path to an absolute one, so that the cd() command always works?

I thought maybe I could first do a cd() to the path where the .vpw file is, but I don't know how to obtain the absolute path of that file either.

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1818
  • Hero Points: 151
Re: How to convert a relative path to an absolute one
« Reply #1 on: May 09, 2023, 12:23:15 AM »
Should be relative to the vpj location.  What we do the most often in our code is something like this:
Code: [Select]
absolute(_ProjectGet_WorkingDir(project_handle),_file_path(_project_name));

You'll need to import stdprocs.e to pick up the _file_path function.