Is there any script function to get the installation directory of Moho?
e.g. "C:\program files\Moho"
Thanks!
Get installation directory of Moho
Moderators: Víctor Paredes, Belgarath, slowtiger
Hello,
Can someone try for me on Windows and Mac that the os.popen() function of lua is working or not? This is a new function of lua 5.1 and it is OK in the Linux version of Moho. My problem is that the os.tmpname() function is not available under Linux, so I can't get the output of os.execute(). For example, try the following script:
Thank you in advance!
Handling directories is a pain in lua. I think if you want to use the install directory, the best way is to ask the user where to find it (maybe there are more than one installed moho on a computer or on a network!). Then you can keep the path in the preferences.
Can someone try for me on Windows and Mac that the os.popen() function of lua is working or not? This is a new function of lua 5.1 and it is OK in the Linux version of Moho. My problem is that the os.tmpname() function is not available under Linux, so I can't get the output of os.execute(). For example, try the following script:
Code: Select all
function trythis:ListDir()
--print the contents of the current directory
local opSys= os.getenv("OS")
local dirCmd= "ls ."
if (opSys) then
if (string.lower(string.sub(opSys, 1, 3)) == "win") then
dirCmd= "dir ."
end
end
print(self:OS_Execute(dirCmd))
end
function trythis:OS_Execute(cmd)
--os.execute, return: standard output, as string
--based on the "luaforge.net/projects/hamster" routines
local f= io.popen(cmd)
if (f) then
local str= f:read("*a")
f:close()
return str
end
return ""
end
Handling directories is a pain in lua. I think if you want to use the install directory, the best way is to ask the user where to find it (maybe there are more than one installed moho on a computer or on a network!). Then you can keep the path in the preferences.
- - - Fazek