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

Dynamic masking of password field with asterisk

  • lefish

    lefish - 2021-08-05

    Hi erveryone,

    I am on CodeSys 3.5.16.

    In the CodeSys login dialog the password field is always masked with three asterisks


    So I came up with my own password field as visu object, which I reference to in the login dialog.

    This is how the visu object looks like:

    The OnMouseDown-Event:

    The OnDialogCLosed-Event triggers the following ST-Code:

    THIS^.str_IOPassword := THIS^.str_Password;
    THIS^.str_MaskedPassword := '';
    FOR THIS^.index := 0 TO LEN(THIS^.str_Password)-1 DO
        THIS^.str_MaskedPassword := CONCAT(THIS^.str_MaskedPassword, '*');
    THIS^.str_Password := '';

    It basically works.

    The only problem is, that str_MaskedPassword contains asterisks in the number of characters of the last entered password.
    The referenced variabl, which is passed to the LoginMgmt is emptied upon clicking OK or CANCEL.

    How can I set the value of the str_MaskedPassword everytime the Login-Dialog is opened?


    Best regards,


    Last edit: lefish 2021-08-05
  • lefish

    lefish - 2021-08-05

    Alright, while writing the above post I came up with the trivial solution myself, which I just successfully tested:

    Simply change the str_MaskedPassword variable to be InOut and handle it the same way like the unmasked str_IOPassword InOut variable...

    Best regards,


    Last edit: lefish 2021-08-05
  • Comingback4u

    Comingback4u - 2021-08-05

    You can also use the function in the VisuDialogs library called VisuDlg_GetPasswordString to convert a string to asterisks. In your "Text Field" you would set the "Text Variable" to VisuDlg_GetPasswordString(stOrg:= str_Password)


Log in to post a comment.