How to render a two-dimensional array correctly with empty/missing 'cell' elements?

Keith Clarke keith.clarke at
Wed Dec 30 08:48:29 EST 2020

Hi folks,
I’m using LiveCode to parse a set of xml files with varying subsets of tags (dmarc reports) into a CSV file.

The utility iterates through the files in the folder and the lines of the files, to identify unique opening tags and their content, all of which get parsed into an array:
- Tags go into aDetails[0][tTagName]
- Values go into aDetails[tFileNumber][tTagName]

This is then displayed as a table, using the function below, borrowed from an LC lesson <>…

function displayArray @pArray
  # create variables that point to the line and column of the array
  local tLineItem, tColumnItem
  # create a variable that stores the output for printing
  local tPrintLine
  put empty into tPrintLine
  # loop through each row of the array
  repeat for each element tLineItem in pArray
    # loop through each column of the array
    repeat for each element tColumnItem in tLineItem
      # write content of the array to tPrintLine
      put tColumnItem & "," after tPrintLine
    end repeat
  # insert a return after each row we have written to tPrintLine
  put return after tPrintLine
  end repeat
  return tPrintLine
end displayArray      

However, the above function seems to assume that all array elements have content, so I’m getting problems where there are empty elements in the xml files coming from various sources.

I’m sure the loop repeating for each element can be refined to check for ‘empty cells’ by the tTagName key in my array but my LC array knowledge is to sparse to begin the search.

Dos anyone have any tips on where I should start looking?

Thanks & regards,

More information about the use-livecode mailing list