Difference between revisions of "var.store"

From Inspired-Lua Wiki
Jump to navigation Jump to search
Line 7: Line 7:
 
== Syntax  ==
 
== Syntax  ==
  
var.'''store(varname, data)'''
+
var.'''store'''(varname, data)
  
 
{| class="wikitable"
 
{| class="wikitable"

Revision as of 11:14, 12 June 2011

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


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)

Parameter Type Description
varname
string The name of the math variable you want to store stuff in.
data
anything the data you want to store in varname. Can be a number, string, table etc.

Example

function on.create()
	var.store("sol",1400000)
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 store some data into the "sol" variable, retrieves the content of the variable sol (string), and prints it on the screen.

See also