Referenced File Folder Path Change

Hi, in my organization we are working on a project with multiple PLCs. They will share the same object structure for some components, but it is currently in its infancy so the structures may change over the course of the project. In an effort to save some effort, I had the idea of using series of common files as Reference Files.

However some of our programmers file structures do not match. So a reference file on my computer for example may not work on another because the reference requires the full file path of the referenced file.

Is it possible to change this to a file path relative to the project? The Referenced files are in a separate folder, but in the same location as the folder containing the Projects.

Hi,
references to files outside the project are always absolute, inside the project they are relative resp. the pathes can be overwritten to be relative by using '\'.

(it looks like the online help is being updated, so please read GUID 95178b83-ec58-4ba5-aafb-e04f33a01e70 and GUID 9e943fd0-8f61-4615-8c3b-c65745d45c52)

For me it would make sense have all of the PLCs in the same Automation Studio project as separate Configurations. In this case you would have all the source code inside the same Automation Studio project and all references would be relative and within the Automation Studio project Requires some setting up and may not always be the best solution, but to give an idea.

Other idea could be using git submodules.

There are different advantages and disadvantages on different approaches, you will just need to find the one that works best for you.

Hi,
I’m pretty sure that you can use in referenced file the ".." notation to get the parent folder.
You may need to edit the package “.pkg” file by hand.
I will test it in an AS6 project and comeback for update on this thread.

Regards,
Florent

Here is an example
TestFolderMultipleProject.zip (99.7 KB)

There is 2 projects (cell0 and cell1). In both project there is a refereced lib and ST program.

This is done in the files /Logical/Package.pkg and Logical/Libraries/Package.pkg

Here is files:
Logical/Libraries/Package.pkg

<?xml version="1.0" encoding="utf-8"?>
<?AutomationStudio FileVersion="4.9"?>
<Package xmlns="http://br-automation.co.at/AS/Package">
  <Objects>
    <Object Type="Library" Language="binary" Description="This library contains function interfaces for IEC 61131-3 operator functions. For the most part, these are mathematical and logical functions.">operator</Object>
    <Object Type="Library" Language="binary" Description="This library contains runtime functions for IEC tasks.">runtime</Object>
    <Object Type="Library" Language="binary" Description="This library contains function interfaces for IEC 61131-3 conversion functions.">AsIecCon</Object>
    <Object Type="Library" Language="binary" Description="The AsTime Library supports DATE_AND_TIME and TIME data types.">astime</Object>
    <Object Type="Library" Language="IEC" Description="This is a shared library" Reference="true">..\Shared\SharedLIB\IEC.lby</Object>
  </Objects>
</Package>

Logical/Package.pkg

<?xml version="1.0" encoding="utf-8"?>
<?AutomationStudio FileVersion="4.9"?>
<Package Version="1.0.0" xmlns="http://br-automation.co.at/AS/Package">
  <Objects>
    <Object Type="File" Description="Global data types">Global.typ</Object>
    <Object Type="File" Description="Global variables">Global.var</Object>
    <Object Type="Package" Description="Global libraries">Libraries</Object>
    <Object Type="Program" Language="IEC" Reference="true">..\Shared\SharedPRG\IEC.prg</Object>
  </Objects>
</Package>

The reference is based on the project path as I see in AS6.3.

The problem of this referenced file / lib / program, is that you cannot use the toolbox on it, AS didn’t let you add a function block in the lib for example. You need to do it by hand.

I was confronted with the same problem some time ago, and the solution I chose was to use git submodules, which allow functionality to be separated into several repositories. This allows you to have different versions in each project, while maintaining the same code base.
It a bit hard first to setup the git submodule but when it’s done, most of git client handle it and it’s relatively easy to manage.

Regards,
Florent

1 Like

Thank you for this!

I would only add that I needed to add another .. to get one more folder out.

Example:
..\..\shared_globals\Shared_Global.typ