Loading a table field with data

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
kpeters
Posts: 112
Joined: Wed Mar 21, 2007 9:32 pm

Loading a table field with data

Post by kpeters » Sun Jun 03, 2007 9:20 pm

While searching for info on how to fill a table field with data from a MySQL query I stumbled upon a post by Jan Schenkel from almost three years ago
refering to undocumented calls like:

revReadCellValue(tLongID,tColumn,tRow,tFormat)
revWriteCellValue tLongID,tColumn,tRow,tValue)
revUpdateDatabase tLongID,tColumn,tRow,tValue)

Is this the best info out there or has some real documentation been created?

TIA
Kai

oliverk
Site Admin
Site Admin
Posts: 53
Joined: Mon Feb 27, 2006 2:16 pm

Post by oliverk » Mon Jun 25, 2007 4:11 pm

Hi Kai,

Although these functions may work fine, I would recommend sticking to the fully supported and documented methods as we could change the semantics of any undocumented functions.

If you need to display data from a database table in a Revolution field, I would suggest taking a look at the revDataFromQuery function, which can provide formatted data suitable for putting straight into a field.

For example, lets say you have a table called "users" with the following description:

- id integer primary key
- firstname text
- lastname text
- approved boolean

Once you have connected to your database, you can retrieve the data from the table using a query like this:

Code: Select all

local tUserData
put revDataFromQuery(tab, return, sgDatabaseId, "SELECT id, firstname, lastname, approved FROM users") into tUserData
if item 1 of tUserData is "revdberr" then
  -- Handle error here
end if

put tUserData into field "Users" of me
If your field is a table field, all you need to do is ensure that the data is formatted with each record on a new line and each column separated by a tab character.

You can easily manipulate the contents of the table field by using the item and line keywords and delimiters.

Hope this is some help.

Regards
Oliver
Oliver Kenyon
Software Developer
Runtime Revolution

Post Reply