The rdfile and rdcmd utilities

rdfile is an extension of the unix cat utility. It reads an ASCII file, passes it through the Questaal file preprocessor, and prints the results to standard output. The preprocessor has capabilities for looping and conditional reading of lines. You can structure output and control flow with algebraic and character variables, which can be declared in the input file itself or on the command line using Questaal’s standard -v and -c command-line arguments.

Questaal programs that read input files such as ctrl.ext also pass the input through the Questaal preprocessor.

rdcmd reads an ASCII file and passed each postprocessed line to a shell, as a command. With rdcmd you can use the input file simultaneously as a script containing instructions, and as the input for the calculation you are doing. Many of the tests in the distribution contain their own instructions for the test.

rdfile examples


Example 1.  Make a list of n+1  (x,y)  pairs for parabola  y=x2/2  in the interval [0,1].

Cut and paste the context of the box below into input.txt.

% repeat i=0:n
% var x=i/n
{x} 1/2*{x^2}
% end

Invoke rdfile -vn=5 input.txt and the output should be

0 1/2*0
.2 1/2*.04
.4 1/2*.16
.6 1/2*.36
.8 1/2*.64
1 1/2*1

Note: Invoking rdfile without the variable assignment -vn=# will result in an error. Alternatively you can include the assignment in the input file, viz

% const n=5

Example 2:  Make a list of points on a line connecting vector M to vector R.

Cut and paste the context of the box below into input.txt :

% vec M[3] 1/2 1/2 0
% vec R[3] 1/2 1/2 1/2

% const n=5
% repeat i=0:n
% var x=i/n
{x*M(1)+(1-x)*R(1)} {x*M(2)+(1-x)*R(2)} {x*M(3)+(1-x)*R(3)}
% end

Invoke rdfile input.txt and the output should be

0 .5 .5 .5
1 .5 .5 .4
2 .5 .5 .3
3 .5 .5 .2
4 .5 .5 .1
5 .5 .5 0

rdcmd examples

Example 1:  is a trivial example that invokes the unix ls command to a string you supply. It illustrates character variable substitution.

Cut and paste the context of the box below into input.txt

ls {abc}

Invoke rdcmd -cabc='input.*' input.txt and you should see

>> ls input.*
input.txt
>>

Other resources

The source codes to rdfile and rdcmd can be found in the bitbucket repository.


Edit This Page