Download 3 Overview - Inductive Automation
Transcript
Appendix C. Scripting Functions
850
another file using system.file.readFileAsBytes).
Syntax
system.file.writeFile( filepath, charData [, append])
Parameters
String filepath - The path of the file to write to.
String charData - The character content to write to the file.
boolean append - If true(1), the file will be appended to if it already exists. If false(0), the file will
be overwritten if it exists. The default is false(0). [optional]
Returns
nothing
Scope
All
system.file.writeFile( filepath, data [, append])
Parameters
String filepath - The path of the file to write to.
byte[] data - The binary content to write to the file.
boolean append - If true(1), the file will be appended to if it already exists. If false(0), the file will
be overwritten if it exists. The default is false(0). [optional]
Returns
nothing
Scope
All
Examples
Example 1:
This code would download a BLOB from a database and save it to a file.
resultset = system.db.runQuery("SELECT file_data FROM Files WHERE id=12")
if len(rs) > 0: # if the query returned anything...
data = rs[0][0] # grab the BLOB at the 0th row and 0th column
filename = system.file.saveFile("MyDownloadedFile.xyz")
if filename != None:
system.file.writeFile(filename, data)
Example 2:
This code would write the contents of a text area to a file.
data = event.source.parent.getComponent("Text Area").text
filename = system.file.saveFile("MyDownloadedFile.txt")
if filename != None:
system.file.writeFile(filename, data)
© 2013 Inductive Automation
Related documents
TBarCode .NET Developer Manual V11
MES User Manual - Inductive Automation
TAC Vista
ISCE manual and installation, JPL
Crystall Ball Manual
2 Overview - Inductive Automation
3D Viewer - Kansas State University
FactorySQL 4.1 User Manual
SQA Higher Computing Unit 2 Software Development
MES User Manual - Inductive Automation
SE-SW5U(-WT) - AutomationDirect
Color Efex Pro 3.0 User Guide