D028868 CR1500 CR1100 CR2700 JavaScript Programming Guide User Manual Page 22 of 41
The Code Corporation
12393 South Gateway Park Place, Suite 600, Draper, UT 84020
+1 (801) 495-2200
FAX +1 (801) 495-0280
In this section, the examples use elements of a time card application that assumes time card records
are maintained as files, organized by employee number. The naming convention for the time card
records is TimeCard<employee_number>.
storage.read
The storage.read method reads a file. This file is converted to UTF-16 for use in
JavaScript.
Example:
var timeInfo = storage.read(“TimeCard1”);
storage.write
The storage.write method writes a file to storage. If the file does not exist, the
Code reader creates it. If there was an existing file of the same name, it is replaced. If
the file contains multi-byte characters, it must be encoded in UTF-8. Example:
var employee57Info;
storage.write(“TimeCard57”, employee57Info);
storage.append
The storage.append method adds data to the end of a file.
Example:
var extraInfo = “extra info”;
storage.append(“timeCard57”, extraInfo);
storage.rename
The storage.rename method renames a file.
Example:
storage.rename(“newEmployeeTime”, “timeCard58”);
storage.erase
The storage.erase method erases a file.
Example:
storage.erase(“newEmployeeTime”);
storage.uploadFile
The storage.uploadFile method uploads a file’s name that match the RegEx, to the
host, over the current active host comm port.
Example:
storage.uploadFile(“timeCard58”);