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/​]
  • What does your input HAVE to be?

    If your serial number comment is ALWAYS a numeric integer (whole number)
    LABEL/SNQUESTION
    C1 =COMMENT/INPUT,NO,FULL SCREEN=NO,
    ENTER SERIAL NUMBER

    IF/C1.INPUT-INT(C1.INPUT)<>0
    COMMENT/OPER,NO,FULL SCREEN=YES,AUTO-CONTINUE=NO,
    Invalid input! Please input
    a serial number with
    only numerical digits
    GOTO/SNQUESTION
    END_IF/​

    If your serial number is ALWAYS a certain length, you can also force the Comment to be a LEN() value.

    Also there's a couple very powerful functions in PCDMIS,
    --the NOT modifier (!)
    --ASCII values CHR() Example: you can create an array of ASCII Values that you want to prohibit then assess the comment as a string to affirm it does NOT have the any of the array characters

    assign\forbidden=Array(CHR(47),CHR(46),CHR(42),CHR (63),CHR(60),CHR(62),CH R(124),CHR(48),CHR(32))
    that FORBIDDEN is your IF_GOTO series of values in an array, plus 32 is the spacebar, which i'm also guessing you don't want.
    with that array, you can do an IF with a do/until all characters in the string are judged.

    --I don't think you can blindly query if the entire input contains any of those characters, by the means in which you were with the IF_GOTO's you posted.
    --or are you trying to prevent the operators from inputting just those characters as a means to bypass the serial number?​

    Another idea would be to implement a barcode scanner and make production give a 3of9 barcode font (it's a free font to download anywhere) barcode to the serialized components. that way, it's impossible to fubar the serial number entry, unless the label was made wrong.
  • If the serial number can only be alphanumeric, use a tracefield, set the input to alphanumeric and it won't allow them to even hit ok.

    Attached Files
  • Its for part serialization, example "LC-CAV2-#1"

    The reason for it is because Windows 10 doesn't support those symbols as I described when you want to save a PDF
  • trying to prevent the operators from inputting just those characters or by accident.
  • You can do that with the INDEX() string function. It returns the location of a string within another string - it returns an integer. If the string is not found, it returns a value of 0.

    So, you can search for what you don't want in the string and if it returns anything other than 0, you know the string contains it.

    Using it, your conditional statements would like something like this:

    C1 =COMMENT/INPUT,NO,FULL SCREEN=NO,
    ENTER SERIAL NUMBER
    ASSIGN/NEWSN=C1.INPUT
    IF_GOTO/ INDEX(NEWSN,"/")>0,GOTO = DEATH
    IF_GOTO/ INDEX(NEWSN,":")>0,GOTO = DEATH
    IF_GOTO/ INDEX(NEWSN,"*")>0,GOTO = DEATH
    IF_GOTO/ INDEX(NEWSN,"?")>0,GOTO = DEATH
    IF_GOTO/ INDEX(NEWSN,"<")>0,GOTO = DEATH
    IF_GOTO/ INDEX(NEWSN,">")>0,GOTO = DEATH
    IF_GOTO/ INDEX(NEWSN,"|")>0,GOTO = DEATH
    IF_GOTO/ INDEX(NEWSN,"0")>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/​


  • Hello,

    if you want you can try this:

               ...
                ASSIGN/V1=C2.INPUT
                ASSIGN/VCOUNTER=0
                DO/
                  ASSIGN/VCOUNTER=VCOUNTER+1
                  IF_GOTO/INDEX("/:*?<>|0",LEFT(MID(V1,VCOUNTER),1))<>0,GOTO = DEATH
                UNTIL/VCOUNTER==(LEN(V1)-1)​
                ...
    
  • Nice!
    It hurt my brain a bit to figure out how that works.
  • C1 =comment/input,no,full screen=no,
    enter serial number
    assign/newsn=c1.input
    assign/vcounter=0
    if_goto/index("\/:*?<>|0",left(mid(newsn,vcounter),1))<>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/
  • hi,

    it looks as if you don't have the loop in it, then only the first character is tested.
    Unfortunately my example doesn't work without loops do / until


    C1 =comment/input,no,full screen=no,
    enter serial number
    assign/newsn=c1.input
    assign/vcounter=0
    if_goto/index("\/:*?<>|0",left(mid(newsn,vcounter),1))<>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/​
  • It just keeps looping and cant come out of it if it encounters a false statement