Expression examples -1-

# Function to reverse the order of a string

string
strreverse(string in)
{
float len = strlen(in);
string result = "";

for (src = len - 1; src >= 0; src--)
result += in(src);

return result;
}

# Function to find the mininum value of two
# floation point numbers

min(v1, v2)
{
if (v1 else
}

# Example to find the mininum element in a vector

float
vecmin(vector vec)
{
min = vec[0];
for (i = 1; i if (vec[i] min = vec[i];
return min;
}

# Example to find all objects which have their
# displ flag set

string
opdisply()
{
string object = run("opls /obj");
string result = "";
nargs = argc9objects);
for (i = 0; i {
string obj = arg(objects, i);
if ( index(run("opset " +obj), " -d on") >= 0)
result += " " + obj;
}
return result;
}

Quote from Tutorial-User guide 5.5