Script TheSky  Version 1.32
Public Slots | List of all members
TextFile Class Reference

The TextFile object. More...

Inheritance diagram for TextFile:

Public Slots

int createNew (QString fileNameWithOutExtension)
 Creates a new text file. More...
 
int openForAppend (QString fileNameWithOutExtension)
 Opens an existing text file for appending. More...
 
int openForRead (QString fileNameWithOutExtension)
 Opens an existing text file for reading. More...
 
void close (void)
 Close the text file.
 
QString readAll (void)
 Reads the entire content of the text file, and returns it as a string. More...
 
QString readLine (void)
 Reads a line of text and returns it. More...
 
bool write (QString qsOut)
 Write a string to the text file. More...
 

Detailed Description

The TextFile object.

The TextFile object provides basic scripted access to a text file. This object by no means offers general purpose text file operations but rather limited scope while still offering the scripter a useful, powerful tool. The following restrictions apply 1) the file name can only contain letters and or numbers 2) the file size on write is limited 3) the path of the file is fixed 4) the extension of the file is fixed (see createNew() for all the specific details).

The TextFileExample.js sample script demontrates use of this object.

This object was added in TheSky build 10055 (see Application::build).

Member Function Documentation

◆ createNew

int TextFile::createNew ( QString  fileNameWithOutExtension)
slot

Creates a new text file.

Calling this method truncates an existing file with the same name.

Parameters
[in]fileNameWithOutExtensionthe desired file name without an extension. The file extension .txt is automatically appended and cannot be changed. The file name can only contain letters and or numbers. The path to the file is fixed and cannot be changed. On Windows the file fixed path is /My Documents/Software Bisque/TheSkyX Professional Edition/ScriptFiles for TheSkyX 32 bit (otherwise "/TheSky Professional Edition 64/") . On Mac the fixed path is /Library/Application Support/Software Bisque/TheSkyX Professional Edition/ScriptFiles The file size is limited to 4 MB when writing.

Possible method return values

◆ openForAppend

int TextFile::openForAppend ( QString  fileNameWithOutExtension)
slot

Opens an existing text file for appending.

Parameters
[in]fileNameWithOutExtensionsee createNew()

Possible method return values

◆ openForRead

int TextFile::openForRead ( QString  fileNameWithOutExtension)
slot

Opens an existing text file for reading.

Parameters
[in]fileNameWithOutExtensionsee createNew()

Possible method return values

◆ readAll

QString TextFile::readAll ( void  )
slot

Reads the entire content of the text file, and returns it as a string.

Avoid this function when working on large files, as it will consume a significant amount of memory. This method returns an empty string if the file is opened with createNew() or openForAppend().

See also
readLine();

◆ readLine

QString TextFile::readLine ( void  )
slot

Reads a line of text and returns it.

This method returns an empty string if the file is opened with createNew() or openForAppend().

◆ write

bool TextFile::write ( QString  qsOut)
slot

Write a string to the text file.

Returns true if the write succeeded or false if the write fails.

ScriptTheSkyX Examples
(C) Software Bisque, Inc. All rights reserved.