Map Life Facts coding question
Posted: 01 Jun 2022 12:18
miketate,
some time ago, we exchanged some emails regarding MLF recognizing the right Berks, and other subtle improvements, one of the improvements was cutting up both ,, and , , parts, equivalently. this is not done in fh.split() but somewhere else, insofar as I can tell, and I cannot find that bit of code in 5.1 MLF which is what I have, mostly because I do not know what I am looking for... can you give me the line numbers where you operate on both ,, and , , because I need my code to work with both situations, and it currently does not.
(example of military attributes:
1. Civil War, US Army,, Company A 16th Army Corps MN Regiment
2. Civil War, US Army, , Company A 16th Army Corps MN Regiment
-- Split a string into fields using sep or dft ','
function rtvFields(str, sep)
local otbl = {}
local pattern = ('([^%s]+)'):format(sep or ',')
str = tostring(str or ' ')
str:gsub(pattern,
function(field)
otbl[#otbl + 1] = (field or ' ')
end
)
return #otbl, otbl
end -- fn rtvFields
this will miss the .. (obvs) in 1, but 2 works.
I need to make it work for both (that is, placeholders; void or spaced are important.
some time ago, we exchanged some emails regarding MLF recognizing the right Berks, and other subtle improvements, one of the improvements was cutting up both ,, and , , parts, equivalently. this is not done in fh.split() but somewhere else, insofar as I can tell, and I cannot find that bit of code in 5.1 MLF which is what I have, mostly because I do not know what I am looking for... can you give me the line numbers where you operate on both ,, and , , because I need my code to work with both situations, and it currently does not.
(example of military attributes:
1. Civil War, US Army,, Company A 16th Army Corps MN Regiment
2. Civil War, US Army, , Company A 16th Army Corps MN Regiment
-- Split a string into fields using sep or dft ','
function rtvFields(str, sep)
local otbl = {}
local pattern = ('([^%s]+)'):format(sep or ',')
str = tostring(str or ' ')
str:gsub(pattern,
function(field)
otbl[#otbl + 1] = (field or ' ')
end
)
return #otbl, otbl
end -- fn rtvFields
this will miss the .. (obvs) in 1, but 2 works.
I need to make it work for both (that is, placeholders; void or spaced are important.