Functions | |
string | FileChooser (string Name, string Pattern) |
Create a dialog box to select a file. | |
list | ReadData (string Filename, string Sep) |
This function reads a text data file. | |
image | ReadImg (string sName) |
Read image from a file. | |
string | ReadText (string sFilename, any_type sData) |
Read the contents of a text file and store it in a string variable. | |
string | ReadVar (string sName, any_type vData) |
Read the contents of a data file and store the data in a variable. | |
string | ReadXML (string sName, any_type lData) |
Read the contents of a XML file and store them in a nested list. | |
void | SaveScreen (string Filename) |
Save the actual visualization screen as bmp image to disk. | |
void | ShowFile (string Name) |
Open a file and show it with the appropriate viewer set by the operating system. | |
void | WriteData (string Filename, list L, string Sep) |
This function writes a list of scalars to a file. | |
void | WriteImg (string sName, image Img) |
Write image to a file. | |
string | WriteText (string sFilename, string sData) |
Write the contents of a string variable to a file. | |
string | WriteVar (string sName, any_type vData, counter iComp) |
Write the contents of a variable to a file in XML format. |
|
Create a dialog box to select a file.
Pattern the user is asked to select a file. The name of the file will then be returned. |
|
This function reads a text data file.
1.2 3.4 -6.2 4.3 1.2543 8.3 9.2 The code ?L = ReadData("Test.dat"); then produces the output L = ((1.2, 3.4, -6.2), (4.3, 1.2543, 8.3, 9.2)) Similarly, if the file looks like this 1.2, 3.4, -6.2 4.3, 1.2543, 8.3, 9.2 then the following code ?L = ReadData("Test.dat", ","); produces the same output L = ((1.2, 3.4, -6.2), (4.3, 1.2543, 8.3, 9.2)) |
|
Read image from a file.
sName . Possible file formats are '.bmp', '.jpg', '.pcx', '.png', '.raw', '.sgi', '.tga', '.tif'. |
|
Read the contents of a text file and store it in a string variable.
|
|
Read the contents of a data file and store the data in a variable.
|
|
Read the contents of a XML file and store them in a nested list.
<?xml version="1.0" encoding="utf-8" ?> <test version="1.0"> Hello World! </test> When this data file is read with ReadXML(), it generates the following nested list in CLUCalc: [ [ test , [ [ [ version , 1.0 ] , [ _content , Hello World! ] , [ _subtree , [ ] ] ] ] ] ] The reserved tags '_content' and '_subtree' are used to reference the content and the subtree of an element. Elements with the same tag name are collected in lists as the following example shows. Consider the following XML data structure.
<?xml version="1.0" encoding="utf-8" ?> <test version="1.0"> <name>a</name> <fun>Hello</fun> <name>b</name> <fun>World</fun> </test> This is mapped to the following nested lists in CLUCalc.
[ [ test , [ [ [ version , 1.0 ] , [ _content , ] , [ _subtree , [ // List of subtree elements by name [ fun , [ // List of elements with tag 'fun' [ [ _content , Hello ] , [ _subtree , [ ] ] ] , [ [ _content , World ] , [ _subtree , [ ] ] ] ] ] , [ name , [ // List of elements with tag 'name' [ [ _content , a ] , [ _subtree , [ ] ] ] , [ [ _content , b ] , [ _subtree , [ ] ] ] ] ] ] ] ] ] ] ] If this data structure is stored in the variable lData, then you can, for example, obtain a reference to the list of elements with tag 'name' with the following script.
// Get name of root element sRootName = lData([1,1]); // Get reference to property list of root element lRootProp -> lData([1,2,1]); // Get content of 'version' property sVersion = lRootProp("version"); // Get reference to subtree of root tree lRootTree -> lRootProp("_subtree"); // Get reference to list of elements with tag 'name' lNameList -> lRootTree("name"); |
|
Save the actual visualization screen as bmp image to disk.
'.bmp' , otherwise the file won't have an extension. An existing file with the same name will be overwritten. The following command saves the contents of the visualization window to the parent directory: SaveScreen( "..\screen.bmp" ); |
|
Open a file and show it with the appropriate viewer set by the operating system.
|
|
This function writes a list of scalars to a file.
ReadData .The code then produces the output L = [[1.1, 2, 3, 4], [1, 2]] L = [[1.1, 2, 3, 4], [1, 2]] |
|
Write image to a file.
sName in the format specified by the extension of the filename. Possible file formats are '.bmp', '.jpg', '.pcx', '.png', '.raw', '.sgi', '.tga', '.tif'. |
|
Write the contents of a string variable to a file.
|
|
Write the contents of a variable to a file in XML format.
|