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.​​
  • Yes, I had to split this up into 2 variables and check them together as you stated otherwise the line was too long.
    I'll still advocate for custom forms all day.
Reply Children
No Data