doc:lua:start
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
doc:lua:start [2011/06/19 19:45] – admin | doc:lua:start [2013/12/29 16:14] – admin | ||
---|---|---|---|
Line 114: | Line 114: | ||
* Flagset(Integer): | * Flagset(Integer): | ||
* id(String): The id is used to add an individual marker to a menu item. This is widely used when one single Lua function should support many menu items. This is descripted in detail in the [[# | * id(String): The id is used to add an individual marker to a menu item. This is widely used when one single Lua function should support many menu items. This is descripted in detail in the [[# | ||
+ | |||
+ | === " | ||
+ | |||
+ | |||
+ | |||
+ | |||
=== pageDone() === | === pageDone() === | ||
Line 174: | Line 180: | ||
Writes //String// to the build in output console. | Writes //String// to the build in output console. | ||
+ | |||
+ | === dbLookup(db-File , searchstring) === | ||
+ | |||
+ | Searches in the //db-file// for all entries with index // | ||
+ | |||
+ | dbLookup() returns a Lua table | ||
+ | | ||
+ | myTable = dbLookup(" | ||
+ | |||
+ | // | ||
+ | * if // | ||
+ | * if // | ||
+ | * if // | ||
+ | |||
+ | When something has been found, than //myTable// contains two sections, //header// and //data//. | ||
+ | |||
+ | The header section is needed in case you don't know in which column your wanted result is stored; you can identify the column by its column header name instead: | ||
+ | |||
+ | col= myTable.header[" | ||
+ | print (col) | ||
+ | 2 | ||
+ | |||
+ | // | ||
+ | |||
+ | |||
+ | The //data// section then contains the found data itself, arranged as a two dimensional array, sorted by rows and columns. | ||
+ | |||
+ | result=myTable.data[row][column] | ||
+ | | ||
+ | **ATTENTION**: | ||
+ | |||
+ | column=3 | ||
+ | row=2 | ||
+ | result=myTable.data[tostring(row)][tostring(column)]) | ||
+ | | ||
+ | | ||
+ | Here after all a piece of sample code | ||
+ | |||
+ | <code lua> | ||
+ | myTable= dbLookupCall(" | ||
+ | |||
+ | print (" | ||
+ | for k,v in pairs (myTable.header) do | ||
+ | print (k," | ||
+ | end | ||
+ | |||
+ | nrOfColumns = myTable.header.size | ||
+ | nrOfRows = myTable.len | ||
+ | |||
+ | print ("Rows x Columns:" | ||
+ | |||
+ | |||
+ | for row = 1 , nrOfRows , 1 do | ||
+ | for column = 1 , nrOfColumns, | ||
+ | | ||
+ | print (cy, cx, myTable.data[tostring(row)][tostring(column)]) | ||
+ | end | ||
+ | end | ||
+ | </ | ||
===== Some Programming Tricks ===== | ===== Some Programming Tricks ===== | ||
Line 215: | Line 280: | ||
By that it's possible without big efforts to fill a menu with real data already during initialization, | By that it's possible without big efforts to fill a menu with real data already during initialization, | ||
- | |||
- |