PDA

View Full Version : Bug with CoreRPG 3.3.12 Column List onInit()



MadBeardMan
November 14th, 2020, 19:51
Hi,

Been having a problem in the Mongoose Traveller ruleset, that some of the 'Padlocks' are appearing on Reference Sheets as Red (correct) yet '_iedit' buttons attached to lists on the sheet are appearing when they shouldn't.

In the CoreRPG code 'common/scripts/column_list.lua' at the top on the onInit(), I've modified it to include debug comments.


function onInit()
Debug.console('CoreRPG here')
if isReadOnly() then
self.update(true);
else
local node = getDatabaseNode();
if not node or node.isReadOnly() then
Debug.console('CoreRPG here3')
self.update(true);
Debug.console('CoreRPG here3.1')
end
end
Debug.console('CoreRPG here4')
end

function isEmpty()
return (getWindowCount() == 0);
end

function update(bReadOnly, bForceHide)
Debug.console('CoreRPG update', bReadOnly)
Debug.console('CoreRPG update', bForceHide)

Note that `update` is called with 'True' as the first argument.

However on inspecting the value of `bReadOnly` parameter in the 'update' function, it's been received as 'nil'.


Runtime Notice: Host session started
Runtime Notice: s'CoreRPG here'
Runtime Notice: s'CoreRPG here3'
Runtime Notice: s'CoreRPG update' | nil
Runtime Notice: s'CoreRPG update' | nil
Runtime Notice: s'CoreRPG here3.1'
Runtime Notice: s'CoreRPG here4'

If the `self` is removed from the onInit() calls to 'update' then the behaviour is correct.

Cheers,
MBM

Moon Wizard
November 15th, 2020, 19:18
I just modified by CoreRPG column_list.lua file to the following code; and got the attached messages when opening a record that used list_column template.



function onInit()
Debug.chat("ON INIT START");
if isReadOnly() then
self.update(true);
else
local node = getDatabaseNode();
if not node or node.isReadOnly() then
Debug.chat("IS READ ONLY INIT 1");
self.update(true);
Debug.chat("IS READ ONLY INIT 2");
end
end
Debug.chat("ON INIT END");
end

function isEmpty()
return (getWindowCount() == 0);
end

function update(bReadOnly, bForceHide)
Debug.chat("UPDATE", bReadOnly, bForceHide);


Just a reminder that "self" is a reference to the top-level layer of any templates; so if you are layering a script on top of this template either within the control definition or via another template. Then, the top-level layer update function will be called by self.update; not the one in the current file. If no update function is defined in higher layers, then it will fall through to this update call.

Regards,
JPG