[thelist] writing out a multidimensional array as a TOC

Matt Warden mwarden at gmail.com
Tue Aug 5 20:47:33 CDT 2008


On Tue, Aug 5, 2008 at 9:27 PM, Joel D Canfield <joel at bizba6.com> wrote:
> my brain is melting; I should know how to do this but it just won't come
> to the surface
>
> I have aryTOC as rs.GetRows
>
> the data looks much like
> [secID]    [secDesc]  [chapID]  [chapDesc]
>   1     Section1Desc    1    Chapter1Desc
>   1     Section1Desc    2    Chapter2Desc
>   2     Section2Desc    3    Chapter3Desc
>
> etc.
>
> multiple sections, multiple chapters within each section
>
> I want to write
>
> Section1Desc
>    Chapter1Desc
>    Chapter2Desc
>    . . .
>    All the chapters in Section1
> Section2Desc
>    allt he chapters in Section2

Assuming your data set is ordered.. I'm going to use it as if it were
a resultset because I don't remember the notation for accessing a
multi-dimensional array in vbscript,. but here's the algorithm

currentSection = ""
loop ' i forget the exact syntax for vbscript
   if currentSection <> aryTOC("secDesc") then
      currentSection = aryTOC("secDesc")
      response.write currentSection ' format as needed
   end if
   response.write aryTOC("chapDesc") ' format as needed
end loop

-- 
Matt Warden
Cincinnati, OH, USA
http://mattwarden.com


This email proudly and graciously contributes to entropy.



More information about the thelist mailing list