Triggers: Difference between revisions

m
no edit summary
mNo edit summary
mNo edit summary
Line 230: Line 230:


== Working with files ==
== Working with files ==
With scripts you can read or write files located in the device's internal memory or on the SD card. All file operations are performed by the File object, which is obtained through a function called file().
With scripts you can read or write files located in the device's internal memory or on the SD card. All file operations are performed by the ''File'' object, which is obtained through a function called ''file()''.


To work with the files, the library should have read/write file access.
To work with the files, the library should have read/write file access.
Line 238: Line 238:
Open a file for read or write operations
Open a file for read or write operations


:;Argument
:; Argument
:: '''name''' &mdash; The name and the full path to the file.<br/>For example, if the file is located on the SD card, the path should be something like /sdcard/example.txt.
:: '''name''' &mdash; The name and the full path to the file.<br/>For example, if the file is located on the SD card, the path should be something like /sdcard/example.txt.


Line 295: Line 295:


====Save an entry into a file in XML format ====
====Save an entry into a file in XML format ====
The entry includes fields: id , title , date.  
The entry includes fields: id , title , date.
 
<source lang="javascript">
<source lang="javascript">
var xml = '<record id="' + entry().field("id") + '">' +  // Format XML record from the entry field values
var xml = '<record id="' + entry().field("id") + '">' +  // Format XML record from the entry field values