Files library

<< Click to Display Table of Contents >>

Navigation:  Project > Scripts > ST language > Embedded functions >

Files library

Previous pageReturn to chapter overviewNext page

createfile(Input1) - used to create file. Input1 contains path to the file. If path contains "/" it means we use the full path. If path doesn't contain "/" the file will be created in DB folder of the application. The function returns TRUE if the file is created.

 

Example:

bool created = createfile(“filename.txt”);

Response:

File is created in the DB folder of the application.

 

Example:

bool created = createfile(“D:/filename.txt”);

Response:

File is created in the root of storage D.

 


deletefile(Input1) - used to delete file. Input1 contains path to the file. If path contains "/" it means we use the full path. If path doesn't contain "/" the file will be created in DB folder of the application. The function returns TRUE if the file is deleted.

 

Example:

bool created = deletefile(“filename.txt”);

Response:

File is deleted from the DB folder of the application.

 


fileexists(Input1) - used to check file exist or not. Input1 contains path to the file. If path contains "/" it means we use the full path. If path doesn't contain "/" the file will be created in DB folder of the application. The function returns TRUE if the file is exist.

 

Example:

bool exist = fileexist(“filename.txt”);

Response:

Check the file with name "filename.txt" exist or not in the DB folder of the application.

 


filedatetime(Input1) - used to get time of the file creation. Input1 contains path to the file. If path contains "/" it means we use the full path. If path doesn't contain "/" the file will be created in DB folder of the application. The function returns time of the file creation in milliseconds since 1 January 1970.

 

Example:

Tags.datetime = datetimefrom("yyyy-MM-dd HH:mm:ss",filedatetime(Tags.filename));

Response:

In the tag with name datetime we'll get date time of the file creation with name in the tag with name filename. (For example: "2020-10-26 12:12:34").

 


renamefile(Input1, Input2) - used to rename file. Input1 contains path to the file you want to rename. Input2 contains new path with new name of the file. If path contains "/" it means we use the full path. If path doesn't contain "/" the file will be created in DB folder of the application. The function returns TRUE if the file is renamed successfully.

 

Example:

renamefile(“filename.txt”,"D:/newfilename.txt");

 


copyfile(Input1, Input2) - used to copy file. Input1 contains path to the file you want to copy. Input2 contains path where you want to copy file. If path contains "/" it means we use the full path. If path doesn't contain "/" the file will be created in DB folder of the application. The function returns TRUE if the file is copied successfully.

 

Example:

renamefile(“filename.txt”,"D:/filename.txt");

 


openfile(Input1) - used to open file. Input1 contains path to the file you want to open. If path contains "/" it means we use the full path. If path doesn't contain "/" the file will be created in DB folder of the application. The function returns TRUE if the file is opened successfully.

 

Example:

openfile(“filename.txt”);

 


closefile() - used to close file. File opened by openfile command is closed.

 

Example:

closefile();

 


checkeof() - used to check end of file. File opened by openfile command is checked. Check the cursor at the end of file or not.

 

Example:

checkeof();

 


writeline(Input1) - used to write line into the file opened by openfile command. Input1 contains line is going to be written.

 

Example:

writeline(“The line is written”);

 


readline() - used to read line from the file opened by openfile command. The function returns line in string format.

 

Example:

string line = readline();

 


writebool(Input1) - used to write boolean value into the file opened by openfile command. Input1 contains boolean value is going to be written.

 

Example:

writebool(true);

 


readbool() - used to read boolean value from the file opened by openfile command. The function returns boolean value.

 

Example:

bool b = readbool();

 


writebyte(Input1) - used to write byte value into the file opened by openfile command. Input1 contains byte value is going to be written.

 

Example:

writebyte(-34);

 


readbyte() - used to read byte value from the file opened by openfile command. The function returns byte value.

 

Example:

byte b = readbyte();

 


writeshort(Input1) - used to write short value into the file opened by openfile command. Input1 contains short value is going to be written.

 

Example:

writeshort(934);

 


readshort() - used to read short value from the file opened by openfile command. The function returns short value.

 

Example:

short b = readshort();

 


writeint(Input1) - used to write int value into the file opened by openfile command. Input1 contains int value is going to be written.

 

Example:

writeint(-45934);

 


readint() - used to read int value from the file opened by openfile command. The function returns int value.

 

Example:

int b = readint();

 


writelong(Input1) - used to write long value into the file opened by openfile command. Input1 contains long value is going to be written.

 

Example:

writelong(8745934);

 


readlong() - used to read long value from the file opened by openfile command. The function returns long value.

 

Example:

long b = readlong();

 


writefloat(Input1) - used to write float value into the file opened by openfile command. Input1 contains float value is going to be written.

 

Example:

writefloat(8.34);

 


readfloat() - used to read float value from the file opened by openfile command. The function returns float value.

 

Example:

float b = readfloat();

 


writedouble(Input1) - used to write double value into the file opened by openfile command. Input1 contains double value is going to be written.

 

Example:

writedouble(9.14);

 


readdouble() - used to read double value from the file opened by openfile command. The function returns double value.

 

Example:

double b = readdouble();

 


writestring(Input1) - used to write string value into the file opened by openfile command. Input1 contains string value is going to be written.

 

Example:

writestring("Hello world");

 


readstring() - used to read string value from the file opened by openfile command. The function returns string value.

 

Example:

string str = readstring();

 


seek(Input1) - used to move cursor's position in the file opened by openfile command. Input1 contains offset of the cursor from the beginning.

 

Example:

seek(10);

 


getfilepos() - used to get cursor's position in the file opened by openfile command. The function returns cursor's position.

 

Example:

long pos = getfilepos();

 


filelength() - used to get length of the file opened by openfile command. The function returns length of the file in bytes.

 

Example:

long len = filelength();