hexagon logo

Testing Operator input for special characters or wild cards

Anyone have an idea how to test and stop operators inputting \/:*?<>| in comments? If it contains those then it will comment back and tell them to try again? im trying to use an if_goto statements.

[C1 =COMMENT/INPUT,NO,FULL SCREEN=NO,
ENTER SERIAL NUMBER
ASSIGN/NEWSN=C1.INPUT
IF_GOTO/NEWSN=="/" ,GOTO = DEATH
IF_GOTO/NEWSN==":" ,GOTO = DEATH
IF_GOTO/NEWSN=="*" ,GOTO = DEATH
IF_GOTO/NEWSN=="?" ,GOTO = DEATH
IF_GOTO/NEWSN=="<" ,GOTO = DEATH
IF_GOTO/NEWSN==">" ,GOTO = DEATH
IF_GOTO/NEWSN=="|" ,GOTO = DEATH
IF_GOTO/NEWSN=="0" ,GOTO = DEATH
GOTO/LIVE
DEATH =LABEL/
IF/1
COMMENT/OPER,NO,FULL SCREEN=YES,AUTO-CONTINUE=YES,TIME DELAY=10,
DO NOT USE SPECIAL CHARACTERS FOR THE INPUT.
TRY AGAIN!
GOTO/C1
END_IF/
LIVE =LABEL/​]
Parents Reply
  • Once this data is input is the format always exactly the same?

    P123456; s00024058; v433356

    7 characters, 9 characters, 7 characters

    If this is 100% repeatable in this format, something I threw together quickly without thought for more controlled filtering.

    C1         =COMMENT/INPUT,NO,FULL SCREEN=NO,
                Scan Barcode
                ASSIGN/V1=RIGHT(LEFT(C1.INPUT, 18),9)
                TRACEFIELD/DISPLAY=NO,REPORT=NO,DISPLAY MESSAGE=New Trace ; New Trace : V1

Children
  • i found something in the help file "understanding basic file I/O concepts" --> "sample code dealing with numbers containing preceding zeros"

    Slight smile

  • This is probably a dumb idea, but I created flow control for if the position of the letter "s" string begins is in any of the possible locations based on the 3 possible character positions providing your format does not change.

    Feel free to share what you figured out so I can learn too.

    $$ NO,
                s00024058; v433356; P123456 --> s is in Position 1
    $$ NO,
                P123456; s00024058; v433356 --> s is Position 10
    $$ NO,
                v433356; P123456; s00024058 --> s is in Position 19
    C1         =COMMENT/INPUT,NO,FULL SCREEN=NO,
                Scan Barcode
                ASSIGN/V1=RIGHT(LEFT(C1.INPUT, 18),9)
                IF/RIGHT(LEFT(C1.INPUT, 1),1) == "s"
                  ASSIGN/V1=RIGHT(LEFT(C1.INPUT, 9),9)
                  GOTO/NEXT
                END_IF/
                IF/RIGHT(LEFT(C1.INPUT, 10), 1) == "s"
                  ASSIGN/V1=RIGHT(LEFT(C1.INPUT, 10),9)
                  GOTO/NEXT
                END_IF/
                IF/RIGHT(LEFT(C1.INPUT, 19),1) == "s"
                  ASSIGN/V1=RIGHT(LEFT(C1.INPUT, 27),9)
                  GOTO/NEXT
                END_IF/
    NEXT       =LABEL/
                TRACEFIELD/DISPLAY=NO,REPORT=YES,DISPLAY MESSAGE=New Trace ; New Trace : V1

  • You could probably do it using the ELEMENT function - it works in a similar way to the InStr visual basic function.

    Element:

    Delimited substring location: ELEMENT(<Integer>, <String1>, <String2>)

    This function returns the nth substring (element) from string2 using string1 as the delimiting text that divides the elements in string2.

    Suppose string2 is "6, 12, 8, 4, 5" and string1 is a comma character ",". The five elements that can be individually retrieved with the element command are "6", "12", "8", "4", and "5".

    PC-DMIS Help Center - 2023.2 (hexagonmi.com)

  • Short and sweet. this works for now which i can control it depending on this configuration. thanks, ill look into the other examples also. thank you guys!