hexagon logo

Variables in Print command for csv file naming.

I have a program where I am looping 15 parts. I am appending my csv file output using print command inside the loop so all the data for the parts on the fixture load end up in the same file. That works fine. Now I want to control the file naming with an operator input variable and Date and Time. Assign the variable values before starting the loop. When I run the program, it hits the print command and brings up a save file window every part iteration. It seems to somehow think that I am proposing a new file name each time. Thank you for any suggestions.

Parents
  • I do something like this with PDFs. However, I do not use the native CSV command within PC-DMIS. I do my own customized CSV to work with our ERP.:

    ---BEFORE THE LOOP----
    
    ASSIGN/PDFINDEX=SYSTEMDATE("yyMMdd")+"_"+SYSTEMTIME("HHmmss")
    ASSIGN/PDFFILE="M:\Quality\CMM Reports\\"+VPN+"\\Data\True Positions\\"+VPN+"_TP_"+PDFINDEX+".PDF"
    
    ---PRINT COMMANDS---
    
    IF/LOOP1=="1"
    PRINT/REPORT,EXEC MODE=END,$
    TO_FILE=ON,OVERWRITE=PDFFILE,AUTO OPEN=OFF,$
    TO_PRINTER=OFF,COPIES=1,$
    TO_DMIS_REPORT=OFF,FILE_OPTION=OVERWRITE,FILENAME=,$
    REPORT_THEORETICALS=ALL,REPORT_FEATURE_WITH_DIMENSIONS=NO,$
    TO_EXCEL=OFF,$
    PREVIOUS_RUNS=DELETE_INSTANCES
    GOTO/L2
    END_IF/
    IF/LOOP1>"1"
    PRINT/REPORT,EXEC MODE=END,$
    TO_FILE=ON,APPEND=PDFFILE,AUTO OPEN=OFF,$
    TO_PRINTER=OFF,COPIES=1,$
    TO_DMIS_REPORT=OFF,FILE_OPTION=OVERWRITE,FILENAME=,$
    REPORT_THEORETICALS=ALL,REPORT_FEATURE_WITH_DIMENSIONS=NO,$
    TO_EXCEL=OFF,$
    PREVIOUS_RUNS=DELETE_INSTANCES
    GOTO/L2
    END_IF/
    L2 =LABEL/
    IF/LOOP1==FORM4
    COMMENT/REPT,
    .
    "TOTAL RUNTIME: "+ELAPSEDEXECUTIONTIME()
    .
    PRINT/REPORT,EXEC MODE=END,$
    TO_FILE=ON,APPEND=PDFFILE,AUTO OPEN=ON,$
    TO_PRINTER=OFF,COPIES=1,$
    TO_DMIS_REPORT=OFF,FILE_OPTION=OVERWRITE,FILENAME=,$
    REPORT_THEORETICALS=ALL,REPORT_FEATURE_WITH_DIMENSIONS=NO,$
    TO_EXCEL=OFF,$
    PREVIOUS_RUNS=DELETE_INSTANCES
    END_IF/
    L3 =LABEL/

    The last print command appends the runtime to the report if the total number of loops equals the total number designated at the beginning of the program.

  • Yes but in pdf reports you are not trying to append to an existing file as far as I am aware.

  • Sure I am. The first command "overwrites" which creates the initial PDF. Then if the Loop is greater than 1, it will append. Once the loop equals the number of parts, then it appends the runtime. 

  • That's exactly where my thought was going on as well using loop  counts. Nice stuff.

  • Ok I can try that. The problem in this case is that it seems to insist that I have to save it as new file. Even though the file name should be the same. Might be able to stop this by defining file path string as a variable rather than referencing the variables in the print command inside the loop.

  • Are you wanting to append to the same file every time you start the program from the beginning? Otherwise, based on the date and time, which is before the loop, it will write a "new" file at Loop=1 and then append to that same file when ever the loop is >1. I have used this method on 50 or so programs with no issues. Now, if you want to append to the same date and time with several new runs, then there will be additional flow control that requires writing and reading the date/time from a txt or csv file. 

  • Yes, set file name with D/T outside loop then append to that file with looped data next run new file. I will try your syntax and if I have the same problem, I will post you the code.

    Thank you so much for your help.

  • I have shared my code and the window that comes up when it executes the print commands. Have found no resolution to this. Tried changing some of the flags with no affect, Thanks for any thoughts.

    C1 =COMMENT/INPUT,NO,FULL SCREEN=YES,
    Enter Operator Name
    C2 =COMMENT/INPUT,NO,FULL SCREEN=YES,
    Enter Batch Number
    C3 =COMMENT/INPUT,NO,FULL SCREEN=YES,
    Enter Cavity Number
    C4 =COMMENT/INPUT,NO,FULL SCREEN=YES,
    Enter part count
    ASSIGN/V1=C1.INPUT
    ASSIGN/V2=C2.INPUT
    ASSIGN/V3=C3.INPUT
    ASSIGN/V4=C4.INPUT
    ASSIGN/CSVTIME=SYSTEMDATE("MMddyyyy")+"_"+SYSTEMTIME("hhmmss")
    ASSIGN/CSVFILE="\\MAPAPP72\Mitutoyo\Hexagon CMM\Programs\Loader Final Programs\DATA\Pusher Cap 51495899_"+V2+"_"+CSVTIME+".CSV"
    VV2 =LOOP/START,ID=YES,NUMBER=1,START=1,SKIP=,
    OFFSET:XAXIS=0,YAXIS=62,ZAXIS=0,ANGLE=0
    VV1 =LOOP/START,ID=YES,NUMBER=1,START=1,SKIP=,
    OFFSET:XAXIS=50.8,YAXIS=0,ZAXIS=0,ANGLE=0
    COMMENT/REPT,
    V1
    COMMENT/REPT,
    V2
    COMMENT/REPT,
    V3
    COMMENT/REPT,
    V4

    __________________________________________________________________________________________________________________________

    PRINT/REPORT,EXEC MODE=END,$
    TO_FILE=ON,AUTO=1849,AUTO OPEN=ON,$
    TO_PRINTER=OFF,COPIES=1,$
    TO_DMIS_REPORT=OFF,FILE_OPTION=INDEX,FILENAME=,$
    REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMENSIONS=NO,$
    TO_EXCEL=ON,APPEND,FILENAME=CSVFILE,AUTO OPEN=OFF,$
    PREVIOUS_RUNS=DELETE_INSTANCES
    WORKPLANE/XPLUS
    REPORT/LABEL, FILENAME= FILE_HEADER.LBL
    WORKPLANE/ZPLUS
    L1 =LABEL/
    ASSIGN/V4=V4+1
    MOVE/INCREMENT,<0,0,20>
    LOOP/END
    LOOP/END
    MOVE/POINT,NORMAL,<69.8505,246.2287,231.8067

Reply
  • I have shared my code and the window that comes up when it executes the print commands. Have found no resolution to this. Tried changing some of the flags with no affect, Thanks for any thoughts.

    C1 =COMMENT/INPUT,NO,FULL SCREEN=YES,
    Enter Operator Name
    C2 =COMMENT/INPUT,NO,FULL SCREEN=YES,
    Enter Batch Number
    C3 =COMMENT/INPUT,NO,FULL SCREEN=YES,
    Enter Cavity Number
    C4 =COMMENT/INPUT,NO,FULL SCREEN=YES,
    Enter part count
    ASSIGN/V1=C1.INPUT
    ASSIGN/V2=C2.INPUT
    ASSIGN/V3=C3.INPUT
    ASSIGN/V4=C4.INPUT
    ASSIGN/CSVTIME=SYSTEMDATE("MMddyyyy")+"_"+SYSTEMTIME("hhmmss")
    ASSIGN/CSVFILE="\\MAPAPP72\Mitutoyo\Hexagon CMM\Programs\Loader Final Programs\DATA\Pusher Cap 51495899_"+V2+"_"+CSVTIME+".CSV"
    VV2 =LOOP/START,ID=YES,NUMBER=1,START=1,SKIP=,
    OFFSET:XAXIS=0,YAXIS=62,ZAXIS=0,ANGLE=0
    VV1 =LOOP/START,ID=YES,NUMBER=1,START=1,SKIP=,
    OFFSET:XAXIS=50.8,YAXIS=0,ZAXIS=0,ANGLE=0
    COMMENT/REPT,
    V1
    COMMENT/REPT,
    V2
    COMMENT/REPT,
    V3
    COMMENT/REPT,
    V4

    __________________________________________________________________________________________________________________________

    PRINT/REPORT,EXEC MODE=END,$
    TO_FILE=ON,AUTO=1849,AUTO OPEN=ON,$
    TO_PRINTER=OFF,COPIES=1,$
    TO_DMIS_REPORT=OFF,FILE_OPTION=INDEX,FILENAME=,$
    REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMENSIONS=NO,$
    TO_EXCEL=ON,APPEND,FILENAME=CSVFILE,AUTO OPEN=OFF,$
    PREVIOUS_RUNS=DELETE_INSTANCES
    WORKPLANE/XPLUS
    REPORT/LABEL, FILENAME= FILE_HEADER.LBL
    WORKPLANE/ZPLUS
    L1 =LABEL/
    ASSIGN/V4=V4+1
    MOVE/INCREMENT,<0,0,20>
    LOOP/END
    LOOP/END
    MOVE/POINT,NORMAL,<69.8505,246.2287,231.8067

Children