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
  • And don't forget quotation mark. CHR(34).

    so your list should look like:
    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,CHR(34))>0,goto = death

    approach is probably best but I get "Line too long error" (maybe cos I'm using v2012) so split it over 2 lines:

    ASSIGN/V20=ELEMENT(1,"/",NEWSN)<>NEWSN OR ELEMENT(1,"\",NEWSN)<>NEWSN OR ELEMENT(1,"*",NEWSN)<>NEWSN OR ELEMENT(1,":",NEWSN)<>NEWSN OR ELEMENT(1,"?",NEWSN)<>NEWSN
    ASSIGN/V21=ELEMENT(1,">",NEWSN)<>NEWSN OR ELEMENT(1,"|",NEWSN)<>NEWSN OR ELEMENT(1,CHR(34),NEWSN)<>NEWSN OR ELEMENT(1,"<",NEWSN)<>NEWSN

    As I understand it, there are 9 special characters:


    Hope this helps.​​
  • 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/





    This works, its hasn't failed me yet.
Reply
  • 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/





    This works, its hasn't failed me yet.
Children
No Data