12.3.5                  File commands and others

·       OPENF (<file name>) - Close the file previously open (if any) and open a disk text file file name for reading. Default file location is in the project directory.

·       READF - Function returning the value of the next number read from the file defined by OPENF command.

·       READS - Function returning the next string read from the file defined by OPENF command.

·       WRITEF  (<value>) - Writes value into udodebug.txt file (located in the project directory).

·       WRITES (<string>) - Writes string into udodebug.txt file (located in the project directory). Control characters like “\n” are allowed.

·       VAR (<text_expression>) - It is a function, which returns value of variable given as text expression.

·       STR (< arithmetic expression >) - It is a function converting arithmetic expression (a number) into string.

·       CODE (<string>, <n>) - A function returning ASCII code of n-th char in string or -1 if n<0 or n>string length.

·       SNAP (<value>) - A function returning value snapped to geometry resolution (1E-5).

·       STL (<x1>,<y1>,<z1>,<x2><y2>,<z2>) - A command drawing STL format section.

·       MESSAGE (<text>) - prints message in Project Info and in QW-Editor Log window. This command allows the user to perform simple UDO script debugging.

·       VERSION  - returns a number of current base version of QW-Editor.

example:

if VERSION>=2016 do

.....................

endif;

 

 

Let us consider the following modification of threeel.udo described in Defining elements, combined elements and materials:

comment="modified example of three elements";

bitmap="threeel0.bmp";

PAR("name", oname, "3elm");

PAR("length ", a, 6);

PAR("width ", b, 5);

PAR("shape ratio top/bottom", sr, 0.5);

PAR("medium", med, air);

PAR("disk file",df, “c:\temp\points.txt”);

ENDHEADER;

TEST( (a>0)&&(b>0), "Dimensions should be positive");

OPENF(df);

h1=READF;

h2=READF;

h3=READF;

TEST( (h1>0)&&(h2>0)&&(h3>0), "Heights should be positive");

.. (continuation like in the original threeel.udo)

 

If the file points.txt contains the consecutive numbers 5 7 3 the result of drawing the modified UDO will be the same as with the original one. Note also that:

·      In the above example full path to the points.txt file has been given. Other possibilities of specifying the file location are summarised in Files used by UDO language and their location chapter.

·      READF function can be also used to overwrite the current values of variables. This opens a way for external modification of the shape of an object drawn using an UDO. Such a possibility is actually often used when QW-3D is applied together with an external optimiser.

 

Go to next Loops in UDO scripts chapter.

Back to Syntax of the User Defined Object (UDO) language chapter.