* luacom

For users to report plugin bugs and request plugin enhancements; and for authors to test new/new versions of plugins, and to discuss plugin development (in the Programming Technicalities sub-forum). If you want advice on choosing or using a plugin, please ask in General Usage or an appropriate sub-forum.
Post Reply
User avatar
Ron Melby
Megastar
Posts: 917
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

luacom

Post by Ron Melby »

luacom does not have a VERSION I can find in _G.

its not the actual issue but one of no useful documentation whatsoever.

COM.NET
COM.WMI

and several other microsoft frameworks have a way to get system and user folderpaths.

https://docs.microsoft.com/en-us/window ... folderpath
https://docs.microsoft.com/en-us/dotnet ... ew=net-5.0

there is a couple examples, but I cannot figure out how to get them to work using luacom. I have gotten as far as not getting hard errors, and a return of nil, but that is the apex of my efforts. I cannot find any code that comes close to doing what I want on the net, other than in visual basic, and it doesn't work when I do my best to use the translated version in luacom. I find it absolutely absurdly impossible that I am the onliest sub-standard lua programmer who needs to get system and user filepaths. Is there anyone who knows how to set up luacom to do this?
FH V.6.2.7 Win 10 64 bit
User avatar
ColeValleyGirl
Megastar
Posts: 5464
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: luacom

Post by ColeValleyGirl »

Luacom is version 1.3 in both FH6 and FH7... Not that that helps you with the actual issue.

I don't have time to dig into it but does os.getenv('HOMEPATH') help at all? There's probably an equivalent for the system path but off the top of my head I can't remember it.
User avatar
ColeValleyGirl
Megastar
Posts: 5464
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: luacom

Post by ColeValleyGirl »

I lied -- it didn't take much time.

Code: Select all

local osEnv = {}
for line in io.popen("set"):lines() do 
  envName = line:match("^[^=]+")
  osEnv[envName] = os.getenv(envName)
end
Give you a table of the names and values of environment varialbe.

Credit where it's due: https://stackoverflow.com/a/29716746/1943174
User avatar
Ron Melby
Megastar
Posts: 917
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: luacom

Post by Ron Melby »

thanks. but I can get environment variables, I can get HOMEPATH, TMP, TEMP, PATH, CPATH, and so on.

what I cannot get thru os.getenv is the path to mydocuments, admintools, appdata and the like. I can take a very educated guess, but I cannot be at all certain how to get the 'virtual' folders path translated to the 'actual' folders path, lets say-- for instance the desktop, and the desktop directory or the various and sundry AppData.

for example I cannot:

_rtx = (('%s/'):format(os.getenv('CSIDL_BITBUCKET'):gsub('\\', '/')))
_rtx = (('%s/'):format(os.getenv('KNOWNFLDERID_RecycleBin'):gsub('\\', '/')))
_rtx = (('%s/'):format(os.getenv('0x000a'):gsub('\\', '/')))
_rtx = (('%s/'):format(os.getenv(10):gsub('\\', '/')))
to get the path to the recycle bin which is the sort of thing I am after.
FH V.6.2.7 Win 10 64 bit
User avatar
ColeValleyGirl
Megastar
Posts: 5464
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: luacom

Post by ColeValleyGirl »

os.getenv('APPDATA') -- roamng data -- or os.getenv('LOCALAPPDATA' )

Are you coding for every woman and her cat? Or just for you -- in which case you could extrapolate from USERPROFILE for the desktop and documents folders (actually, you could probably do this for everyone in a Windows environment).

Out of sheer curiosity, why do you need to get the the recyle bin?
User avatar
Ron Melby
Megastar
Posts: 917
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: luacom

Post by Ron Melby »

yes, appdata is really virtual, not ApplicationData which is the real thing. My pictures is sort of an amalgamation of userprofile pictures and common pictures, userdesktop and destopdirectory are two different animals as well. I may programattically want to send something to the recycle bin, but as it was, it was just an example. I usually try to code for as much as I can whether it is used often or specially.
I am aware that os.getenv can get most, but not all of the %xxx% variables.
FH V.6.2.7 Win 10 64 bit
User avatar
ColeValleyGirl
Megastar
Posts: 5464
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: luacom

Post by ColeValleyGirl »

Even though it's only an example, you can delete a file using os.remove(path) -- no need to know where it ends up.
Post Reply