Applies To:
  • CitectSCADA V7+

Summary:
How can I limit the operators input to a range of values when using the FormNumPad function?

Solution:
 Save the following Cicode into your project and instead call the function CheckValueNumPad function with the same arguments as FormNumPad. For example calling the function from a text tag value the Input, Touch, Up command should be:

CheckValueNumPad("Please enter value", "tag1", 0)

Here the operator input is limited to a value between 50 and 100.

FUNCTION CheckValueNumPad(STRING sTitle, STRING sTag, INT iMode)

INT ReturnNumPad;
INT ReturnMessage;

ReturnNumPad = FormNumPad(sTitle, TagRead("sTag"), iMode)

    IF IsError <> 299 THEN

        IF (ReturnNumPad >= 50) AND (ReturnNumPad <= 100) THEN

            TagWrite(sTag, ReturnNumPad)

        ELSE

            ReturnMessage = Message("Error", "Value must be between 50 and 100", 0)

                IF ReturnMessage=0 THEN
    
                    CheckValueNumPad(sTitle, sTag, iMode)

                ELSE

                END
        END
    ELSE
    END
END


Keywords: