Backtick identifiers

gatto
2025-10-28
2025-11-06
  • gatto

    gatto - 2025-10-28

    Hello, I’m in Codesys 3.5.20.40 and I try to declare the variable ´var1´ but I get an error.

    here : https://content.helpme-codesys.com/en/CODESYS%20Development%20System/_cds_rules.html

    i read :

    Backtick identifiers
    By using backticks, characters can also be used in identifiers that are not normally permitted in identifiers, such as special characters. The acute accent character is used for backticks: ´ (Unicode: U+02CA)
    The use of backticks is recommended in order to be able to use the same identifiers in CODESYS as in other programming languages or documents, such as circuit diagrams.
    Any character may be used between two backticks, except line breaks and other backticks. Keywords are also allowed as identifiers between backticks.
    Examples:
    ´Variable+9´
    ´INT´
    The backticks are part of each identifier and therefore var1 and ´var1´ are two different identifiers.
    Example
    PROGRAM PLC_PRG
    VAR
    var1 : INT;
    ´var1´: INT;
    END_VAR

    var1 := var1 + 1;
    ´var1´ := 12;

    Are there any limitations or is something missing in my development environment?

     
  • Strucc.c

    Strucc.c - 2025-11-05

    Important:
    ` - Backtick - ASCII 96
    ' - Apostrophe or Single Quote - ASCII 39

    In the online help for some reason it renders ’ ...

    The only issue I don't get, why identifiers are still case-insensitive, even within `backtricks`?
    `mPa` and `MPa` for milli-, mega Pascal are the same identifiers, unfortunately... Is this a bug or a feature?

    Otherwise can do pretty nasty things with it:

    // A practical (?) ASCII table served as crazy strict enumeration
    // Just for hangover Monday mornings
    
    {attribute 'qualified_only'}
    {attribute 'strict'}
    TYPE ASCII :
    (
    
        NULL                    := 16#00,
        START_OF_HEADING        := 16#01,
        START_OF_TEXT           := 16#02,
        END_OF_TEXT             := 16#03,
        END_OF_TRANSMISSION     := 16#04,
        ENQUIRY                 := 16#05,
        BELL                    := 16#06,
        ACKNOWLEDGE             := 16#07,
        BACKSPACE               := 16#08,
        HORIZONTAL_TAB          := 16#09,
        LINE_FEED               := 16#0A,
        VERTICAL_TAB            := 16#0B,
        FORM_FEED               := 16#0C,
        CARRIAGE_RETURN         := 16#0D,
        SHIFT_OUT               := 16#0E,
        SHIFT_IN                := 16#0F,
    
        DATA_LINK_ESCAPE        := 16#10,
        DEVICE_CONTROL_1        := 16#11,
        DEVICE_CONTROL_2        := 16#12,
        DEVICE_CONTROL_3        := 16#13,
        DEVICE_CONTROL_4        := 16#14,
        NEGATIVE_ACKNOWLEDGE    := 16#15,
        SYNCHRONOUS_IDLE        := 16#16,
        END_OF_TRANS_BLOCK      := 16#17,
        CANCEL                  := 16#18,
        END_OF_MEDIUM           := 16#19,
        SUBSTITUTE              := 16#1A,
        ESCAPE                  := 16#1B,
        FILE_SEPARATOR          := 16#1C,
        GROUP_SEPARATOR         := 16#1D,
        RECORD_SEPARATOR        := 16#1E,
        UNIT_SEPARATOR          := 16#1F,
    
    
    
        ` `     := 16#20,
        `!`     := 16#21,   
        `$"`    := 16#22,
        `#`     := 16#23,
        `$$`    := 16#24,
        `%`     := 16#25,
        `&`     := 16#26,
        `$'`    := 16#27,
        `(`     := 16#28,
        `)`     := 16#29,
        `*`     := 16#2A,
        `+`     := 16#2B,
        `,`     := 16#2C,
        `-`     := 16#2D,
        `.`     := 16#2E,
        `/`     := 16#2F,
    
        `0`     := 16#30,
        `1`     := 16#31,
        `2`     := 16#32,
        `3`     := 16#33,
        `4`     := 16#34,
        `5`     := 16#35,
        `6`     := 16#36,
        `7`     := 16#37,
        `8`     := 16#38,
        `9`     := 16#39,
        `:`     := 16#3A,
        `;`     := 16#3B,
        `<`     := 16#3C,
        `=`     := 16#3D,
        `>`     := 16#3E,
        `?`     := 16#3F,
    
        `@`     := 16#40,
         A      := 16#41,
         B      := 16#42,
         C      := 16#43,
         D      := 16#44,
         E      := 16#45,
         F      := 16#46,
         G      := 16#47,
         H      := 16#48,
         I      := 16#49,
         J      := 16#4A,
         K      := 16#4B,
         L      := 16#4C,
         M      := 16#4D,
         N      := 16#4E,
         O      := 16#4F,
    
         P      := 16#50,
         Q      := 16#51,
        `R `    := 16#52,
        `S `    := 16#53,
         T      := 16#54,
         U      := 16#55,
         V      := 16#56,
         W      := 16#57,
         X      := 16#58,
         Y      := 16#59,
         Z      := 16#5A,
        `[`     := 16#5B,
        `\`     := 16#5C,
        `]`     := 16#5D,
        `^`     := 16#5E,
        `_`     := 16#5F,
    
        `agrave`:= 16#60,
        `a`     := 16#61,
        `b`     := 16#62,
        `c`     := 16#63,
        `d`     := 16#64,
        `e`     := 16#65,
        `f`     := 16#66,
        `g`     := 16#67,
        `h`     := 16#68,
        `i`     := 16#69,
        `j`     := 16#6A,
        `k`     := 16#6B,
        `l`     := 16#6C,
        `m`     := 16#6D,
        `n`     := 16#6E,
        `o`     := 16#6F,
    
        `p`     := 16#70,
        `q`     := 16#71,
        `r`     := 16#72,
        `s`     := 16#73,
        `t`     := 16#74,
        `u`     := 16#75,
        `v`     := 16#76,
        `w`     := 16#77,
        `x`     := 16#78,
        `y`     := 16#79,
        `z`     := 16#7A,
        `{`{}   := 16#7B,
        `|`     := 16#7C,
        `}`     := 16#7D,
        `~`     := 16#7E,
        DEL     := 16#7F
    
    ) BYTE;
    END_TYPE
    
     

    Last edit: Strucc.c 2025-11-05
  • gatto

    gatto - 2025-11-06

    Hello, thank you for letting me know.

     

Log in to post a comment.