Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

override init value for VAR_GLOBAL CONSTANT in library from project.

Anonymous
2016-08-05
2020-04-13
  • Anonymous - 2016-08-05

    Originally created by: KevinR

    Dear community,

    i'm using VAR_GLOBAL CONSTANTS in an Library to define upper and lowerbound of an array. All VAR_GLOBAL CONSTANTS, have an predefined init value.

    Now i want to predefine the init value from my Project, where i'm using the Library. I tried to override the VAR_GLOBAL CONSTANTS in the Library from the project, but it doesn't work.

    Is there any solution or work arround?

    Thank you in advance!

     
  • rickj - 2016-08-05

    You may find this thread of some use
    l viewtopic.php?f=11&t=6971 l

     
  • Anonymous - 2016-08-05

    Originally created by: scott_cunningham

    For libraries, add a library "Parameter list" object (screenshot below). This will allow you to define a constant that can be changed when the library is used in a project. The online help should give more information - topic parameter list and then sub-subject GVL.

    IMG: lib

     
  • Anonymous - 2016-08-06

    Originally created by: KevinR

    Hello scott,

    thank you for the fast reply.

    I added an Parameter list "Param_XY" in the library:

    VAR_GLOBAL CONSTANT
       // Array Param
       gc_UpBound : INT := 10;
       gc_Length     : INT := 100;
       
       // Timeout Param
       gc_TimeOut    :TIME := T#10S;
    END_VAR
    

    FB in Library with Array

     
    VAR_INPUT
       arrTest : ARRAY [0..gc_UpBound] OF STRING(gc_Length);
    END_VAR 
    

    PRG in Project:

    VAR
       arrXXX: ARRAY [0..gc_UpBound] OF STRING(gc_Length);
    END_VAR
    

    In the PRG i fill the arrXXX (within the range) and then i call the FB in the library and use the declared arrXXX as Input. This works all fine.

    But I can't change the CONSTANT Vars in the Paramter List "Param_XY".

    I tried to add an GVL in the Project:

    VAR_GLOBAL CONSTANT
       // Array Param
       {attribute 'const_replaced'}
       gc_UpBound : INT := 20;
       {attribute 'const_replaced'}
       gc_Length     : INT := 200;
       
       // Timeout Param
       {attribute 'const_replaced'}
       gc_TimeOut    :TIME := T#50S;
    END_VAR
    

    but it doesnt override the paramters in the library and it allways use the parameters from the lib.

    I can't find anything in the help file about that topic expect the attribute 'const_replaced'.

    What I'm doing wrong?

    Thank you in advance.

     
  • Anonymous - 2016-08-07

    Originally created by: scott_cunningham

    Everything was good until your last step. Don't define the variable again in your main project. Instead, from your project, open the library object (like you are going to add a library to your project) and then highlight your library and look at the available objects - you will see you "parameters" and you can insert the value you want.

     
  • Anonymous - 2016-08-08

    Originally created by: KevinR

    Scott - thank you so much for your support!

    This was exactly the right thing what I was looking for.

    Have a nice day!

    cheers

     
  • ssl - 2020-01-03

    scott_cunningham hat geschrieben:
    For libraries, add a library "Parameter list" object (screenshot below). This will allow you to define a constant that can be changed when the library is used in a project. The online help should give more information - topic parameter list and then sub-subject GVL.
    lib-props.png

    Hi guys,
    I'm doing a library where i need to be able to change the library constants from the project where the library is used. I simply can not find anywhere where it is possible to add this "Parameter list". Also I find no reference in the help to such a parameter list? Any surgestions on how to achieve changing library constants from project (In 2.3 you simply declared a variable with the same name in the project)

    It seems that "Parameter list" is removed in 3.5.15.x as well as support for libraries pre. version 3 (2.3 libraries)

     
  • hrimicha - 2020-04-12

    Hi,
    It is maybe a late answer but I faced the same issue and I found the location of the library parameter list as indicated in the photo

     
  • JAPIB

    JAPIB - 2020-04-13

    Hello, I'm trying to do the same thing and I don't understand how to do.
    Into CODESYS HELP they spoke about ParameterList here :
    https://help.codesys.com/webapp/_cds_cmd_save_project_as;product=codesys;version=3.5.15.0 , in the chapter "Before saving a project as a library:"
    "A parameter list is a special type of global variable list." yes, but how to get it ?
    BR

     

Log in to post a comment.