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.

Reply Children
No Data