var.store

From Inspired-Lua Wiki
Revision as of 13:27, 1 June 2011 by Jimbauwens (talk | contribs) (Created page with "var.'''store''' is a function that is part of the Var Library. <br> The function set the content of a variable in the current document. Returns nil when the operation su...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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


The function set the content of a variable in the current document. Returns nil when the operation succeeded, otherwise an error message.

Syntax

var.store(varname, data)
stores data in the variable varname (must be a string).

Example

function on.create()
	var.store("sol","very very very many")
end

function on.paint(gc)
	variable = var.recall("sol") --assuming that sol exists 
	gc:drawString("The diameter of the sun is " .. tostring(variable) .. " KM", 10, 10, "top")
end

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

See also