CAPL #include relative path

8.5k views Asked by At

I am trying to include a *.can file in a CAPL, but I have to set the absolute path

C:\Users\myuser\canoe\simulations\projectX\Function Test\playground.can

I want to use a relative path to include it, but I am not sure what is the correct convention or if it is even posible. I have tried this so far (my CAPL is in projectX folder):

"C:\...\Function Test\playground.can

"Function Test\playground.can"

"/Function Test/playground.can"

"\Function Test \playground.can"

What is the correct way to use a relative path?

5

There are 5 answers

1
sergej On BEST ANSWER

Yes, it is possible. You need to specify the path relative to your projects CANoe configuration (*.cfg) file. For example:

includes
{
    #include "Function Test\playground.can"
}

if your CANoe project is in C:\Users\myuser\canoe\simulations\projectX\

0
J. Stark On

Yes, it is possible. You need to specify the path relative to the path of the CAPL File (*.can).
[Testet with CANoe 11]



If both CAPL files are in the same folder

includes
{
    #include "playground.can"
}

If the CAPL file, which should be inluded is in a subfolder ("TEST")

includes
{
    #include "TEST\playground.can"
}

If the CAPL file, wich should be included is in the top level folder

includes
{
    #include ".\playground.can"
}
0
VioletVynil On

My best practice to obtain the relative path for any file, is

  1. right clicking the Includes group on the CAPL browsers left (overview) window,
  2. Add include...
  3. Then select the desired file, and the CAPL browser will construct the relative path in the editor section of CAPL browser.
0
K Sergiu On

When using include you can use the relative path to your working file like this: #include "SomeFile.cin"

If you need to go one level up you write #include "../SomeFile.cin"

If you need to find the absolute path of your working folder you can use the CAPL function "getAbsFilePath" with the first argument empty. This will return a string containing the full path to your "Configuration" folder which you can use to create a full path string for more specific actions

1
Ashu On

You can set the path in Event Procedure like this:

on key 'a'
{
   setFilePath("C:\\data file directory", 1);
   .... 
   //Write your Code here
}