hexagon logo

Code for remembering past entries of input comments?

We have our CMM operators enter a serial at the beginning of each run and we use that to track the parts through our building. I'd like to make sure that they aren't just entering "1" or something unhelpful.

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 Stuck out tongue closed eyes).
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​
Parents
  • FPTR =FILE/OPEN,C:\PROGRAM FILES\HEXAGON\CMM PRINTOUT ADDRESS\ADDRESS.TXT,READ
    V1 =FILE/READLINE,FPTR,{FN}
    FILE/CLOSE,FPTR,KEEP
    ASSIGN/VDATE=SYSTEMDATE("MM-dd-yy")
    ASSIGN/VTIME=SYSTEMTIME("hh.mm.ss_tt")

    ASSIGN/PN="PART#"
    ASSIGN/FILE=FN + PN + NEWSN + "_" + VDATE + "_" + VTIME + ".PDF"

    PRINT/REPORT,EXEC MODE=END,$
    TO_FILE=ON,APPEND=FILE,AUTO OPEN=OFF,$
    TO_PRINTER=OFF,COPIES=1,$
    TO_DMIS_REPORT=OFF,FILE_OPTION=INDEX,FILENAME=,$
    REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMEN SIONS=NO,$
    TO_EXCEL=OFF,$
    PREVIOUS_RUNS=DELETE_INSTANCES​


    Thank you for the code/help.

    I put this into a test program and I'm trying to follow what it does.
    It opens the text file, but is there supposed to be something in there (since it's set to 'read' at the end) or should it write something to it?
    What is the print command for?
    It looks like the goal to generate a PDF with a name of:
    whats in the txt file + whats entered for the PN variable + NEWSN (serial from an operator input comment?) + the date + the time.
    I'm missing how it then checks this to stop someone from entering the same SN again.


    The FILE/OPEN,........ADDRESS.TXT,READ line didn't seem to do anything so I flipped it over to 'append', and it now is creating a list of the SN's used. Still not sure what I'm supposed to do with that though.
Reply
  • FPTR =FILE/OPEN,C:\PROGRAM FILES\HEXAGON\CMM PRINTOUT ADDRESS\ADDRESS.TXT,READ
    V1 =FILE/READLINE,FPTR,{FN}
    FILE/CLOSE,FPTR,KEEP
    ASSIGN/VDATE=SYSTEMDATE("MM-dd-yy")
    ASSIGN/VTIME=SYSTEMTIME("hh.mm.ss_tt")

    ASSIGN/PN="PART#"
    ASSIGN/FILE=FN + PN + NEWSN + "_" + VDATE + "_" + VTIME + ".PDF"

    PRINT/REPORT,EXEC MODE=END,$
    TO_FILE=ON,APPEND=FILE,AUTO OPEN=OFF,$
    TO_PRINTER=OFF,COPIES=1,$
    TO_DMIS_REPORT=OFF,FILE_OPTION=INDEX,FILENAME=,$
    REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMEN SIONS=NO,$
    TO_EXCEL=OFF,$
    PREVIOUS_RUNS=DELETE_INSTANCES​


    Thank you for the code/help.

    I put this into a test program and I'm trying to follow what it does.
    It opens the text file, but is there supposed to be something in there (since it's set to 'read' at the end) or should it write something to it?
    What is the print command for?
    It looks like the goal to generate a PDF with a name of:
    whats in the txt file + whats entered for the PN variable + NEWSN (serial from an operator input comment?) + the date + the time.
    I'm missing how it then checks this to stop someone from entering the same SN again.


    The FILE/OPEN,........ADDRESS.TXT,READ line didn't seem to do anything so I flipped it over to 'append', and it now is creating a list of the SN's used. Still not sure what I'm supposed to do with that though.
Children
No Data