I'm getting odd results with the following code, which is designed to extract Source Template Definitions from RM. They are stored in the SQLite table as a BLOB, which is just an unstructured array of bytes. If I view the BLOB in SQLite Expert, everything makes sense. I can see the definition displayed as XML in a very similar format to the FH definition files.
Code: Select all
require('fhSQL')
tblT = {}
FileName = 'D:\\OneDrive\\Documents\\FH Plugin Development\\junk.rmgc'
database = fhSQL.connectSQLite(FileName)
SQL = 'SELECT FieldDefs FROM SourceTemplateTable'
ResultSet = database:select(SQL)
for record in ResultSet:rows() do
FieldDef = tostring(record.FieldDefs)
-- FieldDef = FieldDef:sub(1,100)
print(FieldDef:len(), FieldDef)
table.insert(tblT, FieldDef)
end
fhSaveTextFile('D:\\OneDrive\\Desktop\\junk.txt', table.concat(tblT, '\n'))
fhMessageBox(#tblT .. ' records inserted')
There seems to be something in the latter part of the string that is upsetting the plugin.
Any ideas?