Skip to content

Document#

Base class for all documents More...

import Script

Properties#

Name
string errorString
bool exists
string fileName
bool hasChanged
Type type

Methods#

Name
bool close()
bool load(string fileName)
bool save()
bool saveAs(string fileName)

Detailed Description#

The Document class is the base class for all documents. A document is a file loaded by Knut and that can be used in script (either to get data or to edit).

Property Documentation#

string errorString#

Returns the error string if an error occurred while loading the document, otherwise returns an empty string.

bool exists#

Returns true if the document is a file on the disk, otherwise returns false.

string fileName#

Filename of the current document, changing it will load a new file without changing the type. It's better to use a new Document to open a new file.

Changing the filename will: - save the current document automatically - load the new document - put an error in errorString if it can't be loaded

bool hasChanged#

Returns true if the document has been edited, otherwise returns false.

Type type#

Returns the current type of the document, please note that the type is fixed once, and won't change. Available types are:

  • Document.Text
  • Document.Rc

Method Documentation#

bool close()#

Close the current document. If the current document has some changes, save them automatically.

bool load(string fileName)#

Load the document fileName without changing the type. If the current document has some changes, save them automatically. In case of error put the error text in the errorString property.

bool save()#

Save the current document, in case of error put the error text in the errorString property.

bool saveAs(string fileName)#

Save the current document as fileName, the previous file (if it exists) is not changed, and the current document takes the new fileName. In case of error put the error text in the errorString property.