Passing unknown number of referenced variables to a function

Trevor DeVore lists at mangomultimedia.com
Thu Oct 28 15:52:53 EDT 2004


On Oct 28, 2004, at 10:52 AM, Chipp Walters wrote:

> Trevor,
>
> Why not just send back XML from the server and parse it? You could 
> create a single parsing function to extract just the data you're 
> looking for...at least that's how we do it.

I am doing something similar now though I am not using XML.  The server 
app returns something that looks like this:

version=1.0.0&error=0&type=recordset
_rsname=people&_rstype=multirow&_reccount=3
ID	NAME
1	BOB
2	STEVE
4	WHY+NOT
_rsname=person&_rstype=singlerow
ID	NAME	STUFF
1	STEVE	PRETTY+NEAT+GUY

Which I pass to a function for parsing.  If I wanted the 'people' 
result set from the above data which was stored in the tData variable I 
would call:

put getArrayFromDBResult("people", tData) into tDataA

For what I am doing now XML isn't necessary and I can parse the above 
quite easily in Rev.  If I switch to XML in the future I just change my 
getArrayFromDBResult.

The way my database apps are set up is that they can run locally 
(internal network that connects directly to SQL database) or over the 
web where they interface with a PHP application.  I have a standardized 
array structure that I use for dealing with record sets so that the 
code that deals with populating the UI with values doesn't care if the 
data comes from the web or a local database - it just expects to see an 
array with a given structure.

I was hoping to have a function that worked like this:

get getArrayFromDBResult(tData, tPeopleA, tPersonA)

that would parse all the returned data and populate the arrays that I 
passed in.  Since that isn't possible without using globals I opted to 
use this form which works nicely-

put getArrayFromDBResult("people", tData) into tDataA


-- 
Trevor DeVore
Blue Mango Multimedia
trevor at mangomultimedia.com



More information about the use-livecode mailing list