
12: W
EB
S
ERVER
12-18
W
EB
S
ERVER
CPU M
ODULE
U
SER
’
S
M
ANUAL
FC9Y-B1278
JavaScript Functions
When data register monitoring is enabled, device data can be read or written with the following JavaScript functions
included in the system library. Since data register values exchanged via CGI can be directly used in your JavaScript
programs, the values can be flexibly manipulated. For details about CGI interface, see "Appendix" on page A-1.
Reading Device Data
var raw_data = Idec.device_read(device, address, length, driver, net_no)
device: Specify the device type. "D" (data register) can be specified.
address: Specify the device number.
length: Specify the number of devices to read. The valid range is between 1 and 64.
driver: Reserved for the system. Specify 0.
net_no: Reserved for the system. Specify 0.
The device value is returned as string in hexadecimal as “XXXX.” When the length is bigger than or equal to 2, “_“ is
inserted between device values.
Note:
When D2058 is 49910 (C2F6h) and D2059 is 59768 (E978h), request and returned values are as follows:
var raw_data = idec.device_read(“D”, 2058, 2, 0, 0);
raw_data will be “C2F6_E978.”
Writing Device Data
var raw_data = Idec.device_write(device, address, length, driver, net_no, data)
device: Specify the device type. "D" (data register) can be specified.
address: Specify the device number.
length: Specify the number of devices to write. The valid range is between 1 and 64.
driver: Reserved for the system. Specify 0.
net_no: Reserved for the system. Specify 0.
data: Specify the data to write in hexadecimal. When the length is bigger than or equal to 2, “_“ is inserted between
device values.
When writing device data is completed successfully, true is returned. Otherwise false is returned.
Note:
When writing 49910 (C2F6h) to D2058 and 59768 (E978h) to D2059, request and returned values are as follows:
var status_write = idec.device_write(“D”, 2058, 2, 0, 0, “
C2F6
_
E978
”);
When writing data is completed successfully, true is stored in status_write.
Phone: 800.894.0412 - Fax: 888.723.4773 - Web: www.clrwtr.com - Email: [email protected]