omron — WRITE program instruction

WRITE program instruction Details This is a general-purpose data output instruction that writes a record to a specified logical unit. A record can contain an arbitrary list of characters, but must not exceed 512 characters in length. For files that are opened in fixed-length record mode, this instruction appends NULL characters to the output record if it is shorter than the file records. When accessing the TCP/IP device, the record_num parameter enables a server to communicate with multiple clients on a single logical unit. Handles are allocated when a client connects to the server and deallocated when a client disconnects.

During a connection the read instruction that receives data from the TCP logical unit returns the client handle. A write instruction can then use the handle value to send data to the corresponding client. Examples You can write a message to the manual control pendant with the following instructions: ATTACH (1) ;Attach the control pendant WRITE (1) $message ;Output message to pendant DETACH (1) ;Detach the pendant A file with variable-length records can be written to the system disk drive with instructions such as the following:

ATTACH (dlun, 4) "DISK" ;Attach the disk interface FOPENW (dlun) "A:testfile.dat" ;Open a file on drive "A" FOR i = 0 TO LAST($lines[]) ;Loop for all the elements WRITE (dlun) $lines[i] ;to be written END FCLOSE (dlun) ;Close the file DETACH (dlun) ;Release the disk interface Attach to serial line 1 and write a greeting: ATTACH (slun, 4) "SERIAL:1" WRITE (slun) "Hello from serial line 1" Write the string $str to the client defined by the handle, which must have been defined previously when the a message was received. Do not wait for acknowledgment:

WRITE (lun, handle) $str, /N Related Keywords ATTACH program instruction DETACH program instruction FCLOSE program instruction eV+Language Reference Guide, v2.x, 18319-000 Rev A Page 574