1

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?

PySerial Killer
  • 428
  • 1
  • 9
  • 26

5 Answers5

1

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\

sergej
  • 17,147
  • 6
  • 52
  • 89
  • I saw that is a common practice to use `*.cin` instead of `*.can`, to indicate that that file is a resource, not the primary script. This should help you keeping the workspace clean and readable. – Daemon Painter Mar 14 '19 at 08:43
1

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"
}
Community
  • 1
  • 1
J. Stark
  • 11
  • 3
1

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.
VioletVynil
  • 502
  • 5
  • 11
0

You can set the path in Event Procedure like this:

on key 'a'
{
   setFilePath("C:\\data file directory", 1);
   .... 
   //Write your Code here
}
SiHa
  • 7,830
  • 13
  • 34
  • 43
Ashu
  • 1
  • Welcome to StackOverflow: if you post code, XML or data samples, please highlight those lines in the text editor and click on the "code samples" button ( { } ) on the editor toolbar or using Ctrl+K on your keyboard to nicely format and syntax highlight it! – WhatsThePoint Dec 19 '17 at 08:33
0

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

K Sergiu
  • 26
  • 3