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
  • 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/​


Reply
  • 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/​


Children
No Data