print Edit

void print([arg1,...,argN])
Print values to the output window and log file.
V1 Function Name

print prints a comma-separated list of arguments. In Foldit, the output appears in the recipe output window and the scriptlog file (by default, the scriptlog is scriptlog.default.xml).

Each argument to print is converted to a string. In the output, the strings are separated by a tab character. The tab character is normally invisible, and displays as one or move spaces. The number of spaces depends on the tool used to view the output.

For better control of formatting, it's common to use the Lua concatenation operator, ".." (dot dot) to combine multiple arguments into a single string. The concatenation operator doesn't add any spaces or tab characters, so it's up the programmer to provide them.

True/false boolean values are an exception when using concatenation. Use the tostring function to explicitly convert a boolean value before concatenating it.

Example Edit

Comma-separated valuesEdit

With a comma-separated list of arguments, the code:

a = "alpha" 
b = "beta" 
g = "gamma"

print ( "a is", a, "b is", b, "g is", g )

produces output with embedded tab characters:

a is	alpha	b is	beta	g is	gamma

Concatenated valuesEdit

Using the concatenation operator, the code:

a = "alpha" 
b = "beta" 
g = "gamma"

print ( "a is " .. a .. ", b is " .. b .. ", g is " .. g )

produces better-formatted output:

a is alpha, b is beta, g is gamma

The concatenation can also be done outside of the call to print:

a = "alpha" 
b = "beta" 
g = "gamma"

outline = "a is " .. a 
outline = outline .. ", b is " .. b
outline = outline  .. ", g is " .. g

print ( outline )

which produces the same output as the previous example.

Boolean valuesEdit

When printing a true/false boolean value, the code:

local flag = false

print ( "flag = " .. flag )

produces an error:

ERROR: [string "a = "alpha" ..."]:12: attempt to concatenate global 'flag' (a boolean value)

Use the tostring function to print a boolean value:

local flag = false
print ( "flag = " .. tostring ( flag ) )

which produces the output:

flag = false

The tostring function is required any time a boolean value is concatenated.