DataGrid - Looping through all elements, and TSV help
Posted: Sun Nov 22, 2020 9:21 pm
Hi all-
I am brand new to LiveCode. I've used Python and .NET in the past.
How can I loop through every element in a DataGrid, even if I don't know the column names?
Goal: Make a function to pre-process all cells in TSV that I have loaded into the grid. For example, perhaps I want to check for bad characters or fix formatting.
I want to emphasize it should be generic, ie- I don't know the column names or dimension.
I see this example in the help docs but it assumes I know the columns, which I do not:
PS: I'm trying to create a simple app where I import either a CSV or TSV file from Excel and process each cell. I can import the TSV, but LiveCode doesn't seem to process standard TSV conventions. For example, if a TSV cell value is:
.. Then Excel saves this, accord to TSV standards, as:
But LiveCode's import, from what I see, doesn't deal with these extra formattings... Unless there's a library I'm not aware of?
Thanks for your help, excited to get started with LiveCode.
I am brand new to LiveCode. I've used Python and .NET in the past.
How can I loop through every element in a DataGrid, even if I don't know the column names?
Goal: Make a function to pre-process all cells in TSV that I have loaded into the grid. For example, perhaps I want to check for bad characters or fix formatting.
I want to emphasize it should be generic, ie- I don't know the column names or dimension.
I see this example in the help docs but it assumes I know the columns, which I do not:
Code: Select all
put the dgIndexes of group "DataGrid 1" into theIndexes
## Prefix XML
put "<people>" & cr into theXML
## Loop through data, putting into XML format
repeat for each item theIndex in theIndexes
put "<person>" & cr after theXML
put "<first_name>" & theDataA[theIndex]["FirstName"] & "</first_name>" & cr after theXML
put "<last_name>" & theDataA[theIndex]["LastName"] & "</last_name>" & cr after theXML
put "<title>" & theDataA[theIndex]["Title"] & "</title>" & cr after theXML
put "</person>" & cr after theXML
end repeat
## Close root XML tag
put "</people>" after theXML
Code: Select all
He said "hello" to me.
Code: Select all
"He said ""hello"" to me."
Thanks for your help, excited to get started with LiveCode.