Code: Select all
local strParseFact = "%[(FCT%-[_%u%-]+%-([IF])([EA]))%]%c+Name=(.-)%c.-Label=(.-)%c(.-)\r\n{END}%c" --order of these elements in the fact file seems standard
local strFacts = strFacts:gsub("(%c+%[FCT)","\r\n{END}%1").."\r\n{END}"
for ident, recordtype, facttype, name, label, strdetail in strFacts:gmatch(strParseFact) do
local hidden = strdetail:match("Hidden=(%a)%c") or "N"
local strFacts inserts \r\n{END} before each [FCT line and tags \r\n{END} on the end.
That ensures every Fact Def is terminated by \r\n{END} prior to next Fact Def.
for ident, ... is much as before but does not extract hidden and sident is renamed ident
local hidden extracts Hidden= value from strdetail or defaults to "N"
A small change to local strParseFact means ident now captures the desired FCT-... code for later.
So later on local ident=sident:match(".*%[(FCT%-.-%-)$")..recordtype..facttype is not needed.
It seems to work with Colin's files.
I have a small variant of the above that does not need \r\n{END} to be inserted, but it is a bit more obscure.