Getting Started > Use Lua Scripts > Method Reference > Document Objects Methods

Document Objects Methods
addField
Adds a new field to the document.
Syntax
addField ( String fieldname, String fieldvalue )
Arguments
 
appendContent
Appends content to the existing content of the document.
Syntax
appendContent ( String content )
Arguments
 
copyField
Copies a field to a certain name.
Syntax
copyField ( String sourcename, String targetname )
Arguments
 
deleteField
Deletes a field from a document.
Syntax
deleteField ( String fieldname )
Arguments
 
getContent
Gets the content for a document.
Syntax
String ( getContent )
Returns
The document content.
getFieldNames
Gets all the field names for the document.
Syntax
getFieldNames ( )
Returns
A table of all the field names.
getFieldValue
Gets the value of a field on a document.
Syntax
getFieldValue( String fieldname )
Arguments
 
Returns
A string containing the value.
getFieldValues
Gets all values from all fields that have the same name.
Syntax
getFieldValues( String fieldname )
Arguments
 
Returns
A table of all the field values.
getNextSection
The document object passed to the script's handler function in fact represents the first section of the document. This means the functions previously detailed only read and modify the first section. This method returns the next section in the document when sectioned.
Syntax
LuaDocument getNextSection ()
Example
To perform operations on every section, for example:
local section = document
while section do
-- Manipulate section
section = section:getNextSection()
end
Returns
A document object that contains the next DRE section.
hasField
Checks to see if a field exists for a document.
Syntax
hasField ( String fieldname )
Arguments
 
Returns
A Boolean: true if the field exists, false otherwise.
renameField
Changes the name of a field from one name to another.
Syntax
renameField ( String currentname, String newname )
Arguments
 
setContent
Sets the content for a document.
Syntax
setContent ( String content )
Arguments
 
setFieldValue
Sets the value of a field on a document.
Syntax
setFieldValue( String fieldname, String newvalue )
Arguments
 
writeStubIdx
Writes out a stub idx document (a metadata file used by IDOL applications).
Syntax
writeStubIdx( String filename )
Arguments
 
Returns
A Boolean: true if written, false otherwise.