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

About codesys

saban57
2020-06-22
2020-06-24
  • saban57 - 2020-06-22

    First of all hello.
    I have two questions for you.
    1 question:
    I want to standardize variable names in my projects. Can I extract the universal variables I have defined to an excel file?
    I tried but I failed. I can do this process in "comforpoint" software of "honeywell" but I couldn't do it in plc designer.
    My 2nd question:
    Can I auto-align data types when defining variables?
    I need to write a script for this process?

     
  • JAPIB

    JAPIB - 2020-06-22

    Hello,

    1Β°) You can copy a selected area from excel and paste it into CODESYS only if your Global Variable List (or Local List) is in Textual view.

    For example, if My excel part is :
    A | B | C
    ---------- | ---------- | ------
    iVar1 | INT | Comment 1
    iVar2 | INT | Comment2

    When I past into a GVL, I get this :
    VAR_GLOBAL
    iVar1 INT Comment 1
    iVar2 INT Comment 2
    END_VAR

    But then you need to correct format, by adding special caracters ":;(",for example :
    iVar1 : INT; (Comment 1)*

    2Β°) I think there is no command to auto-align data types.
    You can simply do this with Tabulation.
    You can also see GVL in Tabular view. In this mode you can also sort variables by name, by type, ...
    But when you look at GVL again in Textual view, you will see it when it was before (witjout sort, without align, ...)

    BR

     
  • saban57 - 2020-06-24

    Thanks for the answer, but I'm looking for more professional answers.

     

    Last edit: saban57 2020-06-24
  • helge - 2020-06-24

    You could also use concatenate functions to add together the variables for GVL
    F10 cell:

    =CONCATENATE(
    IF(B10<>"",
    CONCATENATE(B10,":",C10,
    IF(D10<>"",":=",""),
    IF(D10<>"",D10,""),";"),""),
    IF(E10<>"","(",""),
    IF(E10<>"",E10,""),
    IF(E10<>"","
    )",""))

    using char(9) in excel gives you horizontal tab, but will be pasted as a string ""
    =CONCATENATE(
    IF(B10<>"",
    CONCATENATE(B10,CHAR(9),":",C10,
    IF(D10<>"",":=",""),
    IF(D10<>"",D10,""),";",CHAR(9),CHAR(9)),""),
    IF(E10<>"","(",""),
    IF(E10<>"",E10,""),
    IF(E10<>"","
    )",""))

    if you are not using any " in your GVL list it is possible to find and replace in codesys and replace " with an empty space.

     

    Last edit: helge 2020-06-24

Log in to post a comment.