Getting a single column of a datagrid

Peter Haworth pete at mollysrevenge.com
Mon Mar 21 22:09:22 EDT 2011


There's a printkeys function in the datagrid library: send "printkeys" to group "Datagrid1", same format as I think you referred to for the SQLYoga printkeys.  There is a caveat that it only prints the first line of each key but that might be OK for you.

Pete Haworth

On Mar 21, 2011, at 5:18 PM, Bob Sneidar wrote:

> You may remember a while back my wanting a quick way to extract a single column of data from a datagrid without having to go through a repeat loop? Well if you use Trevor's sqlYoga, it comes with a neat little function called printkeys(). If you have it, try this trick: 
> 
> Let's say you have a datagrid called "myDatagrid" with 3 columns, columna, columnb, columnc. You just want columnc. 
> 
> -- get text of the array data
> put the dgData of group "myDatagrid" into aArray
> put printKeys(aArray) into theData -- now we have text
> 
> -- at this point you need to know the name of your column
> filter theData with "*columnc: *" -- now just the columnc lines
> 
> -- isolate everything before the first value which is leading spaces, 
> -- the column name, a colon and a trailing space, the same for all lines	
> put word 2 of theData into theWord
> put offset(theWord, theData) into firstChar
> 
> -- now let's delete everything before the values on each line	 
> replace char 1 to firstChar - 1 of theData with empty in theData
> put theData -- this is now just the data in columnc
> 
> It would be nice if printkeys() was public domain but I don't think it is. Still, sqlYoga is a good investment anyways. Heck I might have paid what he charges for sqlYoga just for that function! ;-)
> 
> Bob
> 
> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
> 





More information about the use-livecode mailing list