Your Products have been synced, click here to refresh
I think a script would do this much more quickly, but here's a solution for only inside of PC-DMIS if you don't want to mess with scripts.
- Operator is asked to input a name.
- Invalid characters are assigned to an array.
- Using nested loops each character of the submitted string is then compared against each element of the array.
- If a match is found it details where it was found and then goes back to the input.
The longer the string, the longer it takes to execute. The longer the list of invalid characters, the longer it takes to execute.
I would hazard a guess that the code gurus here could come up with a cleaner more efficient way.
$$ NO,====================INPUT VALIDATION================= GETINPUT =LABEL/ C1 =COMMENT/INPUT,NO,'Type a Name:' $$ NO,======DEFINE VARIABLES========= ASSIGN/BADCHARS=ARRAY("!","@","#","$","%","^","&","*","<",">","?","`","~","(",")","[","]",":",";",",","-","_","=","/","|","{","}","\\") ASSIGN/VAR_STRING=C1.INPUT ASSIGN/VAR_COUNTER=1 ASSIGN/VAR_LENGTH=LEN(VAR_STRING) $$ NO,======BEGIN FIRST LOOP TO CYCLE THROUGH INPUT STRING ========= WHILE/VAR_COUNTER <= VAR_LENGTH ASSIGN/VAR_CHAR=MID(VAR_STRING,VAR_COUNTER-1,1) ASSIGN/ELEMENT_NUMBER=1 $$ NO,======BEGIN SECOND LOOP TO COMPARE CHAR AGAINST ARRAY ELEMENTS ========= DO/ ASSIGN/V1=BADCHARS[ELEMENT_NUMBER] IF/VAR_CHAR==V1 COMMENT/OPER,NO,"Invalid character of " + VAR_CHAR + " at position " + VAR_COUNTER + " in the input of " + VAR_STRING GOTO/GETINPUT PROGRAM/END END_IF/ ASSIGN/ELEMENT_NUMBER=ELEMENT_NUMBER + 1 UNTIL/ELEMENT_NUMBER > LEN(BADCHARS) $$ NO,======END SECOND LOOP ========= ASSIGN/VAR_COUNTER=VAR_COUNTER+1 END_WHILE/ $$ NO,======END FIRST LOOP ========= COMMENT/OPER,NO,"The string of " + VAR_STRING + " passed validation." $$ NO,===================END VALIDATION CODE====================
I tried one of those once...
Didn't accomplish what you wanted did it?
You kept saying, "enter the wrong number again and you'll get shocked...".
Why did you get mad when I entered the wrong number?
© 2024 Hexagon AB and/or its subsidiaries. | Privacy Policy | Cloud Services Agreement |