Page 1 of 1

I want to display the value of the address specified in the description

Posted: Sat Apr 06, 2024 5:06 pm
by edomsa
Hello.

For example, if "456" is stored in the value of "address 00112233", how can I make the description automatically display "456"?

Thank you in advance.

Re: I want to display the value of the address specified in the description

Posted: Sat Apr 06, 2024 10:04 pm
by LeFiXER
You can update the description of a memory record with Lua:

Code: Select all

local descriptionToDisplay = 'The value of  address [ 00112233 ] is: '
local entry = getAddressList().getMemoryRecordByDescription('the text which is in the description section goes here')
if entry then
   entry.Description = descriptionToDisplay .. entry.Value
end

Re: I want to display the value of the address specified in the description

Posted: Sat Apr 06, 2024 11:31 pm
by panraven
Check this 1st viewtopic.php?p=345558#p345558
Then the function can be :

Code: Select all

local al = GetAddressList()
local mr = al.getMemoryRecordByID(1234) -- your target record
if mr then
  mr.OnGetDisplayValue = function(mr, val)
    mr.Description = val -- it may depend on other attribute of the mr, eg if it displayed as hex or signed etc
  end
end
another example:

Code: Select all

...
  mr.OnGetDisplayValue = function(mr, val) 
  -- avoid attribute check to have a consistent hex display, which work also for float type 
    local v, a = mr.NumericalValue, mr.currentAddress
    v = math.tointeger(v) and string.format('0x%X',v) or val
    mr.Description = string.format('%s @ %X', v, a) -- a is 0 if the address is no known
  end
...
The function does not change the 'Value' displayed (no return true, <changed_display>),
but use onGetDispalyValue as a onTimer function to auto-update the Description instead.
But the description may change, we should identify the memory record by other way but not description,
for example, by its ID (copy the record, paste it in editor to lookup it from the xml )

Re: I want to display the value of the address specified in the description

Posted: Sun Apr 07, 2024 5:02 am
by edomsa
LeFiXER wrote:
Sat Apr 06, 2024 10:04 pm
You can update the description of a memory record with Lua:

Code: Select all

local descriptionToDisplay = 'The value of  address [ 00112233 ] is: '
local entry = getAddressList().getMemoryRecordByDescription('the text which is in the description section goes here')
if entry then
   entry.Description = descriptionToDisplay .. entry.Value
end
panraven wrote:
Sat Apr 06, 2024 11:31 pm
Check this 1st viewtopic.php?p=345558#p345558
Then the function can be :

Code: Select all

local al = GetAddressList()
local mr = al.getMemoryRecordByID(1234) -- your target record
if mr then
  mr.OnGetDisplayValue = function(mr, val)
    mr.Description = val -- it may depend on other attribute of the mr, eg if it displayed as hex or signed etc
  end
end
another example:

Code: Select all

...
  mr.OnGetDisplayValue = function(mr, val) 
  -- avoid attribute check to have a consistent hex display, which work also for float type 
    local v, a = mr.NumericalValue, mr.currentAddress
    v = math.tointeger(v) and string.format('0x%X',v) or val
    mr.Description = string.format('%s @ %X', v, a) -- a is 0 if the address is no known
  end
...
The function does not change the 'Value' displayed (no return true, <changed_display>),
but use onGetDispalyValue as a onTimer function to auto-update the Description instead.
But the description may change, we should identify the memory record by other way but not description,
for example, by its ID (copy the record, paste it in editor to lookup it from the xml )
Thanks to you, I can now display the value in the description!
Thank you so much!