I figured all this out using the well-written Help file code examples in PCDMIS 4.3MR1.
It's useful for exporting your data, especially if you only need to output some of your data to Excel in a certain format.
Step 1: At the beginning of the program, the operator is prompted to enter the serial # of the part being run, and this input is assigned to variable V1.
C1 =COMMENT/INPUT,YES,'Serial Number:' ASSIGN/V1=C1.INPUT
(Not shown: the program checks two holes and dimensions their Positions)
Step 2: A pair of Position Dimension results are assigned to variables VOD and VID
ASSIGN/VOD=OD_HOLE_POSITION.TP.DEV ASSIGN/VID=ID_HOLE_POSITION.TP.DEV
Step 3: Then the variables V1, VOD, and VID are concatenated into a string and assigned to a new variable VRALL. The plus signs, spaces, and quotes are very necessary to make sure the values of the variables and the commas are correctly done.
ASSIGN/VRALL=V1+","+VOD+","+VID
Step 4: we run a quick check to see if the target file we want to dump data into exists.
If the file is there PCDMIS will give the variable VEXIST1 the value of 1, if it's missing then it gets zero.
VEXIST1 =FILE/EXISTS,C:\datafolder\\datadumpfile.CSV
Step 5: If this file is not there, well then we can make a new one! We can even set it up with headers.
The IF function will only cause the lines of code between IF and END_IF to be exectuted if the IF statement is true. Therefore, if the file already exists and VEXIST now equals 1 not 0, and this step will be skipped.
The FPTR is a file-pointer function called up by FILE that handles the file opening, reading, writing, and closing commands.
In this example, the FILE command calls a filepointer named FTPR, then uses it with OPEN to create a new file, then WRITELINE four times to add the header information, then CLOSE with KEEP which saves it.
IF/VEXIST1==0 FPTR =FILE/OPEN,C:\datafolder\\datadumpfile.CSV,WRITE FILE/WRITELINE,FPTR,#,OD_HOLE,ID_HOLE FILE/WRITELINE,FPTR,Nominal,0,0 FILE/WRITELINE,FPTR,U.Toler,0.003,0.003 FILE/WRITELINE,FPTR,L.Toler,0,0 FILE/CLOSE,FPTR,KEEP END_IF/
Step 6: OK, now the actual writing of the data to the file.
Notice that the file-pointer's OPEN command has the choice APPEND selected and not OVERWRITE, and that the next command is WRITELINE.
This is so that during each subsequent part run the value of the variable VRALL (Step 3) gets added to the file as a new single line.
FPTR =FILE/OPEN,C:\datafolder\\datadumpfile.CSV,APPEND FILE/WRITELINE,FPTR,VRALL FILE/CLOSE,FPTR,KEEP
Step 6: If you open the resulting datadump.csv file in Notepad you'll see the commas.
The first 4 lines are the header info and were written when the file was created back in Step 5.
The next lines are the actual data from running the program through twice, on parts with serial numbers 777 and 778.
#,OD_HOLE,ID_HOLE
Nominal,0,0
U.Toler,0.003,0.003
L.Toler,0,0
777,0.0022,0.0022
778,0.0019,0.0025
But if you open it up in Excel the commas will be translated as cell dividers and each value will be in it's own cell.
Attached Files