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

Local Variable of Visu accessible from "Execute ST code"

  • macros8 - 2023-06-21


    I wanted to use local variables in my script related to event mouseclick.

    But I have found out that for Execute ST code those local variables are not visible (even in Input assistant).
    The strange is that if I use function Write/Toggle variable those variables are available for use.

    Do you know if there is any chance to use there variable inside the script. It would be much easier for use and keep HMI part separated from PLC part.

    Thanks a lot.

  • macros8 - 2023-07-18


    just up of the topic;)
    IsnΒ΄t there any possibility of using local variables of screen in corresponding Input configuration event - Execute ST code?
    It would be really helpful.

    Just update: Even in other input actions they can be used, e.g. Open Dialog etc. See picture. I still do not get why they are hidden for ST-Code.

    Thanks a lot.


    Last edit: macros8 2023-07-18
  • Fless

    Fless - 2023-07-18


    you can use local variables in the ST code action
    it's just not shown in the input assistant.

    as workaround use

    • macros8 - 2023-07-19

      Hi Fless,

      awesome, I believed itΒ΄s somehow possible.

      Thanks a lot.

    • macros8 - 2023-07-19

      Hi Fless,

      may I have a couple additional question to local vars?

      1) Is it possible to monitor value of them during Login?
      2) Are they initialized always as soon as the visualisation is opened/closed?
      (I struggle a little bit how to realized initialization of some values when the screen is opened/closed -> usually in HMI sw there are scripts corresponding to those events but I cannot find easy way in Codesys visu for that -> only create PLC program to handle that which is not as easy;)).

      Btw. -> your hint works perfectly.

      Thanks a lot.


Log in to post a comment.