Wiki Home

Array Browser


Namespace: Wiki
Download my ILX (inline expression evaluator) from the Universal Thread. Does arrays, collections, et al. Nice code, though! --- John Koziol

* Program aBrow
* By CarlKarsten

* demos function aBrow()

local ;
   laDir(1), ;
   laClasses(1), ;
   laStru(1)
	
* Grab an array of file name info
wait window "adir()" nowait
aDir( laDir, home()+"*.*" )
aBrow( @laDir )

* Grab an array of classes
wait window "aVcxClasses()" nowait
AVCXCLASSES( laClasses, home()+ 'FFC\_Base' )
aBrow( @laClasses )

* Make an array out of the structure used to show aVcxClasses (all char)
wait window "aFields()" nowait
afields( laStru )
aBrow( @laStru )

* This is the structure structure (and where the foolishness it stops.)
wait window "aFields() again" nowait
afields( laStru )
aBrow( @laStru )

return


function aBrow( taArray )
* Makes a cursor out of a two-dimensional array
* and browses it

local ;
   lnRows, ;
   lnCols, ;
   laStru(1), ;
   lnI, lnJ, ;
   lcTyp, lnSiz, lnDec, ;
   lcRow

* Figure out size of array
lnRows = ALEN(taArray,1)
lnCols = max( ALEN(taArray,2), 1 )

dimension laStru(lnCols, 5)
lcRow = ""
for lnI = 1 to lnCols
   * Create structure array 
   lcCol = ltrim(str(lnI))	
   laStru( lnI, 1 ) = vartype( taArray( 1, lni ) ) + lcCol
   laStru( lnI, 2 ) = "C"
   lnSiz = 1
   for lnJ = 1 to lnRows
      lnSiz = max( lnSiz, len( trans( taArray( lnJ, lnI ))))
   endfor
   laStru( lnI, 3 ) = lnSiz
   laStru( lnI, 4 ) = 0

   * Create "insert into" values

   if !empty( lcRow )
      lcRow = lcRow + ", " 
   endif
   lcRow = lcRow + "transform( taArray(lnI,"+lcCol+") )"

endfor

* Make a cursor with fields defined by laStru
create cursor qArray from array laStru

* Add rows using a string of transform(taArray(lnI,1))...
for lnI = 1 to lnRows
   insert into qArray values ( &lcRow )
endfor

go top
browse

return
* eof

Contributors: Carl Karsten
Category Code Samples
( Topic last updated: 1999.09.01 01:05:57 AM )