Write, Bureaucrats, Administrators
4,332
edits
mNo edit summary |
mNo edit summary |
||
Line 333: | Line 333: | ||
:<small>'''Trigger script:'''</small> | :<small>'''Trigger script:'''</small> | ||
<source lang="javascript"> | <source lang="javascript"> | ||
f = file("/sdcard/myfile.txt"); // Open | f = file("/sdcard/myfile.txt"); // Open myfile.txt on the SD card | ||
// it will be created | // If no file, it will be created | ||
f.writeLine("one"); // Write | f.writeLine("one"); // Write "one" as a line to the file | ||
f.writeLine("two"); | f.writeLine("two"); | ||
f.writeLine("three"); | f.writeLine("three"); | ||
f.close(); // Close | f.close(); // Close & save. Until closed, | ||
// the | // the file is still empty | ||
var a = f.readLines(); // Read all lines of the file into the array a | var a = f.readLines(); // Read all lines of the file into the array a | ||
</source> | </source> | ||
Line 349: | Line 349: | ||
:<small>'''Trigger script:'''</small> | :<small>'''Trigger script:'''</small> | ||
<source lang="javascript"> | <source lang="javascript"> | ||
var xml = '<record id="' + entry().field("id") + '">' + // Format XML record | var xml = '<record id="' + entry().field("id") + '">' + // Format XML record | ||
'<title>' + entry().field("title") + '</title>' + | '<title>' + entry().field("title") + '</title>' + // from entry field values | ||
'<date>' + entry().field("date") + '</date>' + | '<date>' + entry().field("date") + '</date>' + | ||
'</record>'; | '</record>'; | ||
f = file("/sdcard/" + entry().field("title") + ".xml"); // | f = file("/sdcard/" + entry().field("title") + ".xml"); // File name is Entry Name | ||
f.write(xml); // Save XML data | f.write(xml); // Save XML data to the file | ||
f.close(); // Close the file | f.close(); // Close the file | ||
</source> | </source> |