beautypg.com

Pm designer operation manual – B&B Electronics WOP-2121V-N4AE - Manual User Manual

Page 446

background image

4

14

PM Designer Operation Manual

14-37

CHAPTER 14 USING MACROS

WRITE_FILE

Format

P1

= WRITE_FILE(P2,P3,P4 )

Data Type

U

Function

Writes P4 bytes of data in P3 to file P2 and saves the completion code in P1.

P1 (I)

The word to receive the completion code of the operation. If the completion code is 0, the
operation succeeded; Otherwise the operation failed.

P2 (I)

The file handle of the file.

P3 (I)

The memory block (or byte array) that stores the data to be written to the file.

P4 (I/C)

Number of bytes to be written to the file.

Example 1

$U200

=WRITE_FILE(

$U100

,

$U150

,

30

)

/* Write 30 bytes of data stored in the memory block

starting from $U150 to the file specified by the file handle in $U100. */

CLOSE_FILE

Format

P1

= CLOSE_FILE(P2,P3 )

Data Type

U

Function

Closes an opened file P2 and saves the completion code in P1.

P1 (I)

The word to receive the completion code of the operation. If the completion code is 0, the
operation succeeded; Otherwise the operation failed.

P2 (I)

The file handle of the file to be closed.

Example 1

$U200

=CLOSE_FILE(

$U100

)

/* Close the file specified by the file handle in $U100. */

DELETE_FILE

Format

P1

= DELETE_FILE(P2 )

Data Type

U

Function

Deletes a file named P2 and saves the completion code in P1.

P1 (I)

The word to receive the completion code of the operation. If the completion code is 0, the
operation succeeded; Otherwise the operation failed.

P2 (I)

The byte array that contains the filename or the full pathname of the file to be deleted. The name
is a null-terminated string and has only ASCII characters in it.

Example 1

$U10

=

“test.txt”

$U200

= DELETE_FILE(

$U10

)

/* Delete the file “test.txt”. */

RENAME_FILE

Format

P1

= RENAME_FILE(P2,P3 )

Data Type

U

Function

Renames file P2 with new name P3 and saves the completion code in P1.

P1 (I)

The word to receive the completion code of the operation. If the completion code is 0, the
operation succeeded; Otherwise the operation failed.

P2 (I)

The byte array that contains the filename or the full pathname of the file to be renamed. The
name is a null-terminated string and has only ASCII characters in it.

P3 (I)

The byte array that contains the new filename. The name is a null-terminated string and has only
ASCII characters in it.

Example 1

$U10

=

“test.txt”

$U50

=

“new.txt”

$U200

= RENAME_FILE(

$U10

,

$U50

)

/* Rename the file “test.txt” to “new.txt”. */