On Mon, May 14, 2012 at 12:01 PM, Oliver Sims <
oliver.s...@simsassociates.co.uk> wrote:
> I've always thought that a "grid" collection type would be very useful. By
> "grid" I mean a combination of directory (or table) and array, so that I
can
> have a 2-dimensional collection with headers like this (for example):
...
> Has anyone come across this as a requirement for ooRexx? Btw, I'm not
trying
> to re-invent SQL.
It just so happens that I recently played around some with this. I found
that an array of arrays worked very well, for my purposes.
Each row is an array with the same number of items as the columns, so each
item in the array is a row. The first row is always the column headers. I
thought it worked well.
The arg 'rs' is an array, each item in the array is an array:
::routine printResultSet
use arg rs
say 'Result:'
colCount = rs[1]~items
rowCount = rs~items
line = ''
headers = rs[1]
do j = 1 to colCount
line ||= headers[j]~left(25)
end
say line
say '='~copies(80)
do i = 2 to rowCount
line = ''
record = rs[i]
do j = 1 to colCount
line ||= record[j]~left(25)
end
say line
end
return 0
/* output */
Result:
id type_id name
=============================================
86 4 A1 Sauce
213 9 All Day Sucker
212 9 Almond Joy
189 8 Apple
129 7 Apple Cider
190 8 Apple Pie
I found a 2-dimensional array did not work well. I was thinking of writing
my own result set class, but I didn't see that it would gain much over just
using the array of arrays approach.
--
Mark Miesfeld
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Oorexx-users mailing list
Oorexx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-users