I've been working on some code to save the last 10 entries to a .txt file and then check that when someone enters a new serial, but it's only about half working (and I have almost no idea what I'm doing with the File/ command ).
I'd like it to return an operator comment that says "Please use a unique serial number".
Can anyone lend some help?
Here's what I have, but feel free to ignore all of this and go another route if you prefer:
USERINPUT =COMMENT/INPUT,NO,FULL SCREEN=NO, Please enter unique serial number: ASSIGN/UNIQUE_SN=USERINPUT.INPUT ASSIGN/USER_SN=USERINPUT.INPUT=="" $$ NO, ASSIGN/COUNT_SN=0 WHILE/COUNT_SN<10 ASSIGN/COUNT_SN=COUNT_SN+1 ASSIGN/SN_MEMORY_FILE="C:\USERS\PUBLIC\DOCUMENTS\HEXAGON\ PC-DMIS\SN_MEMORY_"+COUNT_SN+".TXT" V1 =FILE/EXISTS,SN_MEMORY_FILE,SN_EXISTS IF_GOTO/SN_EXISTS,GOTO = SKIP_SN $$ NO, Checking serial number in file. FPTR =FILE/OPEN,SN_MEMORY_FILE,WRITE V2 =FILE/READLINE,SN_HANDLE, FILE/CLOSE,SN_HANDLE,KEEP IF/SERIALNUMBER=="sn_line" END_IF/ SKIP_SN =LABEL/ END_WHILE/ IF/SN_MEMORY_FILE USED =LABEL/ COMMENT/OPER,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO, serial number has been used before on this lot. try again. END_IF/ $$ NO, ASSIGN/SN_FILENAME="C:\USERS\PUBLIC\DOCUMENTS\HEXAGON\PC-DMIS\SN_MEMORY_"+(COUNT_SN+1)+".TXT" FPTR =FILE/OPEN,SN_FILENAME,READ FILE/WRITELINE,SN_FILENAME,sn_handle FILE/CLOSE,SN_HANDLE,KEEP