* luacom differences FH6 -> FH7 ??

For plugin authors to discuss plugin programming
Post Reply
User avatar
Mark1834
Megastar
Posts: 2534
Joined: 27 Oct 2017 19:33
Family Historian: V7
Location: South Cheshire, UK

luacom differences FH6 -> FH7 ??

Post by Mark1834 »

According to the KB, it is the same version of luacom in FH6 and FH7. This simple plugin, which prints the FH app subfolders when run in the plugin editor, works as expected in FH7.

Code: Select all

require 'luacom'
FSO = luacom.CreateObject('Scripting.FileSystemObject')
folder = FSO:GetFolder(fhGetContextInfo('CI_APP_DATA_FOLDER'))
for _, F in luacom.pairs(folder.SubFolders) do
	print(F.Path)
end
However, FH6 doesn't like the luacom.pairs statement for iterating over a collection.

Any ideas for getting it working in both versions, please?
Mark Draper
User avatar
tatewise
Megastar
Posts: 28486
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: luacom differences FH6 -> FH7 ??

Post by tatewise »

I seem to recall that I had the same problem years ago with my backward compatibility libraries.
So I had to resort to using the Enumerator method:

Code: Select all

require 'luacom'
FSO = luacom.CreateObject('Scripting.FileSystemObject')
folder = FSO:GetFolder(fhGetContextInfo('CI_APP_DATA_FOLDER'))
tblEnum = luacom.GetEnumerator(folder.SubFolders)
local tblAttr = tblEnum:Next()
while tblAttr do
	print(tblAttr.Path)
	tblAttr = tblEnum:Next()
end
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
User avatar
Mark1834
Megastar
Posts: 2534
Joined: 27 Oct 2017 19:33
Family Historian: V7
Location: South Cheshire, UK

Re: luacom differences FH6 -> FH7 ??

Post by Mark1834 »

Thanks Mike. It’s early scouting for a potential new plugin, generalising something I’ve developed for my own use. There will be other differences as well, so I may just stick with FH7 only so I can easily go back to fhFileUtils() when its WINE/Crossover issues are fixed.
Mark Draper
Post Reply