var.recallstr

From Inspired-Lua Wiki
Jump to: navigation, search

var.recallstr is a function that is part of the Var Library.


The function returns a the content of a math variable in the current document as a string. If it cannot be converted to a string, it returns nil and an error message.

Syntax[edit]

var.recallstr(varname)
returns the content of the variable varname (must be a string).

Example[edit]

function on.paint(gc)
	variable = var.recall("sol") --assuming that sol exists 
	gc:drawString("The diameter of the sun is " .. variable .. " KM", 10, 10, "top")
 
	--the difference with the other script in the recall page is that you don't need to use tostring for numbers
end

This code retrieves the content of the variable sol (number), and prints it on the screen.

See also[edit]