26
« Last post by TTalma on March 21, 2024, 06:45:58 PM »
I have made a module file 'PocketPositions.Lua' with a bunch of functions.
In the screen load script I added the following:
-- Pocket Positions
package.loaded.PocketPositions = nil
PocketPositions = require "PocketPositions"
From a tab On enter script I have:
local pocketNums = PocketPositions.GetUsedPocketNumbers()
if pocketNums[1] ~= nil then
wx.wxMessageBox("pocketNums[1] ="..tostring(pocketNums[1]))
table.sort(pocketNums)
local pocketStr = ""
for i=1, #pocketNums do
pocketStr = pocketStr .. pocketNums[i] .. "|"
end
wx.wxMessageBox("pocketStr="..pocketStr)
scr.SetProperty("GROUPBOX_CurrentToolPocket", "Strings", pocketStr)
else
wx.wxMessageBox("pocketStr=nil")
end
the function 'PocketPositions.GetUsedPocketNumbers()' looks like:
-- Gets a table of the pocket numbers that are configured
function PocketPositions.GetUsedPocketNumbers()
local PocketNums={}
local n=0
-- make sure the pockets have been loaded
if PocketDetails == nil or PocketDetails[0] == nil then
PocketPositions.ReadPocketData()
end
for k,v in pairs(PocketDetails) do
n=n+1
PocketNums[n]=k
end
return PocketNums
end
When it calls the function 'PocketPositions.ReadPocketData()' (which is also in the 'PocketPositions.Lua' file) I get an error that 'PocketPositions' is null.
If I step through 'PocketPositions.ReadPocketData()' in the script editor it works fine.
Any idea what's happening and how I fix it?