Sample Code for Write Line

The sample code below should be entered inside the Edit window's Command mode and not inside the File I/O dialog box.

Suppose you want to export some measured XYZ values to a data file. The following code allows you to input a feature label and a data file and send the X,Y, and Z data for that feature to a data file.

C1=COMMENT/INPUT,Type the label of the feature.

,to use.

C2=COMMENT/INPUT,Type the name of the file to write

,to (include the complete path).

FPTR=FILE/OPEN,C2.INPUT,APPEND

ASSIGN/FEATNAME=C1.INPUT

ASSIGN/ALLVALS=FEATNAME.X+","+FEATNAME.Y+","+FEATNAME.Z

COMMENT/OPER,"Text to write is: "+ALLVALS

FILE/WRITELINE,FPTR,ALLVALS

FILE/CLOSE,FPTR

Code Explanation

Some of this code is similar to that explained in "Sample Code for Read Character" or in "Sample Code for Read Line".

Only explanations unique to this example are given here.

FPTR=FILE/OPEN,C2.INPUT,APPEND
This line opens the file specified in the C2 comment for appending, and assigns it to the file pointer, FPTR. If instead, you change APPEND to WRITE, then existing content in the data file will get overwritten.

ASSIGN/FEATNAME=C1.INPUT
This line assigns the string of the feature label from C1.INPUT to the user defined variable, FEATNAME.

ASSIGN/ALLVALS=FEATNAME.X+","+FEATNAME.Y+","+ FEATNAME.Z
This line gives the user defined variable ALLVALS the value of FEATNAME.X,FEATNAME.Y,FEATNAME.Z, in other words it now holds the X, Y, and Z values of the feature label typed into the C1 input comment.

FILE/WRITELINE,FPTR,ALLVALS
This line writes the values contained in ALLVALS to the file specified by the file pointer, FPTR.

Command Mode Commands after Comments

After you insert a PC-DMIS comment, to type additional PC-DMIS commands in Command Mode, you must first press Enter twice after the COMMENT command. This tells PC-DMIS that you no longer want to add text to the comment but are ready to add a new command.