The following function displays the contents of an array, but only if the array has one or two dimensions:

function displayArray(aArg, nColWidth)

local nElement, nCols, nRows, nCol, nRow

#define DEFAULT_WIDTH 2 

   if argcount() < 2 

      nColWidth = DEFAULT_WIDTH 

   endif 

   do case 

      case aArg.dimensions == 1 

         ? replicate("-", nColWidth * aArg.size) 

         ? 

         for nElement = 1 to aArg.size // Display elements 

            ?? aArg[ nElement ] at nColWidth * ( nElement - 1 ) 

         endfor // in a single line 

      case aArg.dimensions == 2 

         nRows = alen( aArg, 1 ) // Determine # of rows 

         nCols = alen( aArg, 2 ) // Determine # of columns 

         ? replicate("-", nColWidth * nCols) 

         for nRow = 1 to nRows 

            ? // Each row on its own line 

            for nCol = 1 to nCols // Display each row as before 

               ?? aArg[ nRow, nCol ] at nColWidth * ( nCol - 1 ) 

            endfor 

         endfor 

      otherwise 

         msgbox("Error: only 1 or 2 dimensions allowed", "Alert") 

   endcase