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/​]
  • maybe there was a typo in the end condition or counter?
    In my test, the loop only runs as long as there are characters in C1.INPUT
  • THIS WORKS, but apparently it doesn't like \ key. wont input

    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,GOTO = DEATH
    IF_GOTO/INDEX(NEWSN," ")>0,GOTO = DEATH
    IF_GOTO/INDEX(NEWSN,"0")<1,GOTO = DEATH
    IF_GOTO/1,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/
    GOTO/LIVE
    LIVE =LABEL/​
  • Put a backslash before the " that you want PC-DMIS to ignore. i.e.:

    IF_GOTO/INDEX(NEWSN,"\"")>0,GOTO = L1
  • thats not the point haha but thanks for the input
  • once it sees say "1-c1-* " it will go into an endless loop because nothing stops it after it finds the last character just starts over again 1 then - then c then 1 ect.
    need to stop the loop once it encounters the index and comment to the operator to fix the c1.input
  • reference the ascii value then. CHR(92) is the "\"
  • Oh if you want to check for a backslash, do the same:
    IF_GOTO/INDEX(NEWSN,"\\")>0,GOTO = L1

  • This works too. alot easier also
    TRACEFIELD/DISPLAY=NO,REPORT=NO,DISPLAY MESSAGE=NO SPECIAL CHARACTERS OR INPUT LENGTH > 11 CHARACTERS ; NEWSN : NEWSN
  • I think has the best solution here imo.
    What I used to for my programs is condense everything into a couple lines using OR.

    REDO =Label
    ​​​​​If/ELEMENT(1,"/",C1.INPUT)<>C1.INPUT OR ELEMENT(1,"*",C1.INPUT)<>C1.INPUT OR ELEMENT(1,"?",C1.INPUT)<>C1.INPUT OR...

    And so on all in one line..

    Comment/OPER TRY AGAIN WITH NO SPECIAL CHARACTERS!!
    GOTO/REDO
    End_If/

    Continue on..

    That's how I used to do it. Now I have a custom form that opens at the beginning of each program asking to fill out all info on one form. A script runs on the input sections so if a special character is used, it won't even let them enter it or continue without filling out all of the info properly. All of that info saves to a text file and the program will pull that info from the text file and populate in the form no matter what CMM is used. Handier than filling out multiple comment boxes.

  • This seems to do the trick!! Thank you for the input!


    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,goto = death
    if_goto/len(newsn)>17,goto = death
    goto/live
    death =label/
    if/1
    comment/oper,no,full screen=yes,auto-continue=yes,time delay=10,
    "do not use more than 17 and/or special characters for the input."

    try again!

    Newsn
    "is an invaild input"
    goto/c1
    end_if/
    goto/live
    live =label/​