Code: Select all
require("luacom")
local FSO = luacom.CreateObject("Scripting.FileSystemObject")
function rtv_canon_parts(_CFN)
local _CFP = _CFN:match("(.*[/\\])")
if _CFP == _CFN then
error("no file provided.")
end
if FSO:FolderExists(_CFP) then
local _fil = FSO:GetFileName(_CFN)
local _ext = FSO:GetExtensionName(_CFN)
local _xt = (".%s"):format(_ext)
_fil = _fil:gsub(_xt, "")
return _CFP, _fil, _ext
end
error("directory does not exist")
end
require("iuplua")
iup.SetGlobal("CUSTOMQUITMESSAGE", "YES")
iup.SetGlobal("UTF8MODE", "YES")
iup.SetGlobal("UTF8MODE_FILE", "YES")
WS_ENTER = true
WS_CANCEL = false
WS_Cancel = "Cancel"
WS_cancel = -1
WS_ERR = 2
WS_OK = "OK"
WS_ok = 0
WS_YES = "Yes"
WS_NO = "No"
WS_Ignore = "Ignore"
WS_Retry = "Retry"
WS_Abort = "Abort"
local objext = {
asm = ".asm", -- assembled
dsm = ".dsm", -- disassembled
boc = ".boc", -- binary object code
BOC = ".BOC", -- BINARY OBJECT CODE
irp = ".irp", -- intermediate representation program
rwc = ".rwc", -- refactor working code
}
-- exe
local exe = {
["5.1"] = {
epth = '"C:/Program Files (x86)/Lua/5.1/"',
opth = "C:/Users/admin/Desktop/IRP/5.1/",
},
["5.3"] = {
epth = '"C:/Program Files (x86)/Lua/5.3.6/"',
opth = "C:/Users/admin/Desktop/IRP/5.3/",
},
}
local src = ("%s/Plugins/*.fh_lua"):format(fhGetContextInfo("CI_APP_DATA_FOLDER"):gsub("\\", "/"))
local _dq = '"'
local epth
local opth
local pth
local fil
local ext
-- slt 5.1 5.3
function sltVER()
local Opt = 0
local WS_RC
local txtOpt = {}
WSTitle = "Version"
txtOpt[0] = "5.1"
txtOpt[1] = "5.3"
WS_RC, Opt = iup.GetParam(WSTitle, nil, ("Table Type: %%o|%s|%s|\n"):format(txtOpt[0], txtOpt[1]), Opt)
if not Opt then
Opt = 0
end
_slt["_ver"] = { fn_key = WS_RC, ix = (Opt + 1) or 0, parm = txtOpt[Opt] or "" }
return _slt["_ver"]
end -- fn sltVER
local _CFN, WS_rc = iup.GetFile(src)
if WS_rc == WS_cancel then
return
end
if WS_rc == WS_ok then
pth, fil, ext = rtv_canon_parts(_CFN)
local _ver = sltVER()
if _ver.fn_key == WS_CANCEL then
return
end
epth = exe[_ver.parm].epth
opth = exe[_ver.parm].opth
opth = ("%s%s"):format(opth, fil)
end
local BOC = ("%sluac.exe -o %s%s%s%s %s%s%s"):format(epth, _dq, opth, objext["BOC"], _dq, _dq, _CFN, _dq)
local dsm = ("%sluac.exe -l -l > %s%s%s%s %s%s%s"):format(epth, _dq, opth, objext["dsm"], _dq, _dq, _CFN, _dq)
local b = os.execute(BOC)
local d = os.execute(dsm)
return
simple program really, the bottom line is the last 4 or 5 sentences. The problem is not in the code, unless its in the delivery to the OS.
I build a command in BOC and dsm I then execute it.
these are actual builds
BOC = "C:/Program Files (x86)/Lua/5.1/"luac.exe -o "C:/Users/admin/Desktop/IRP/5.1/Map Life Facts.BOC" "C:\ProgramData\Calico Pie\Family Historian\Plugins\Map Life Facts.fh_lua"
dsm = "C:/Program Files (x86)/Lua/5.1/"luac.exe -l -l > "C:/Users/admin/Desktop/IRP/5.1/Map Life Facts.dsm" "C:\ProgramData\Calico Pie\Family Historian\Plugins\Map Life Facts.fh_lua"
b and d wiil contain 1 nothing else to capture and the files are not build in the Desktop folder & etc
but if I copy the commands and paste them in a command prompt, the files appear and there are no warnings or errors ... is there an obvious problem here? is there a clever way to see why these are not working in the program but on the command prompt with some alternative coding?
Thanks.
Editing note: Ron submitted some amended code, which I've incorporated in this original post (with a bit of formatting to make it more readable).