Skip to content

File Manipulation

SMath Studio provides the wfile(), rfile(), and dfile() functions for writing data to a file, reading data from a file, and deleting an existing file. Before using these functions, you need to make sure the program has access to these files.

SMath Studio installation folder location

By default, the files used for reading and writing are located at /SMath Studio Installation Folder/user, where /SMath Studio Installation Folder/ is usually C:\Program Files (x86)\SMath\SMath Studio\.

On operating systems starting with Windows Vista, this folder requires administrator rights to read and write files in it. To let the program work with user files, copy its contents to another location that the application, running under your account, has permission to access — for example, to the "My Documents" folder.

Writing data to a file

You can use the wfile() function to write data to a file. Examples:

a := 2.5
wfile(a, file01)=1      Writes the variable name ("a") to the file "file01".
wfile(2.5, file02)=1    Writes the value "2.5" to the file "file02".

You can open these files with, for example, Notepad. As the first argument of wfile(), you need to use the numeric value of the calculation result you want to write to the file. Using a variable reference will only write its name to the file. The file name may only contain letters and digits.

wfile(2,4..19, file03)  Writes the string "range(2,4..19)" to the file "file03".

Reading from a file

To read data from a file, use the rfile() function. The following examples use the files file01, file02, etc. from the earlier examples. The result of reading from a file can be displayed with the "=" sign, or assigned to a variable with the ":=" sign. Examples:

Displaying the result of reading:

rfile(file02)=2.5   using the "=" command
rfile(file02)->5/2  using "Ctrl+."

Assigning the value to a variable:
a:=rfile(file02)       a=2.5    a->5/2

Deleting files

Use the dfile(filename) function to delete files from the /SMath Studio Installation Folder/user folder. Examples:

dfile(file01)=1
dfile(file02)=0

This page is based on a legacy wiki article by Ruslan Shakirov.