HP Forums
Dynamically changing a list in a library - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: General Forum (/forum-4.html)
+--- Thread: Dynamically changing a list in a library (/thread-17268.html)



Dynamically changing a list in a library - cahlucas - 07-20-2021 08:36 PM

Hi all,
For an application that I want to make, it would be convenient for me if I can modify a list that exists in a library. That is, I can add various objects to that list so that I can use them at a later time. My question is whether that is possible, and if so, how can I achieve this? I know there is a program that allows you to change the ID of a library. So I need something that allows me to add various objects to a list that is part of a library. Maybe someone can give me a hint, or even a program to achieve this goal. Sincerely, Karel.


RE: Dynamically changing a list in a library - Han - 07-21-2021 01:24 AM

(07-20-2021 08:36 PM)cahlucas Wrote:  Hi all,
For an application that I want to make, it would be convenient for me if I can modify a list that exists in a library. That is, I can add various objects to that list so that I can use them at a later time. My question is whether that is possible, and if so, how can I achieve this? I know there is a program that allows you to change the ID of a library. So I need something that allows me to add various objects to a list that is part of a library. Maybe someone can give me a hint, or even a program to achieve this goal. Sincerely, Karel.

Is there a reason to not use a user variable to store the data that you anticipate would change? While it is possible to do in a library, it is not a simple task. Libraries are stored with a CRC at the end. You would have to create a copy of your library, compute the difference in size of the existing list and new list, "punch a hole" in your copied library large enough to insert the new list, recompute offsets (possibly), recompute the CRC, and then detach the old library, store the new library, and either attach the modified library (or force a warmstart). And your code would have to be in assembly. If you store your list as the very last object in your library, then recalculating the offsets would be trivial. However, if you have several such lists, then it can be a bit cumbersome. Then there is the memory cost during the moment two copies of your library exists (the old one and the new one). There is also the issue of detaching a library whose code is running in memory. To get around it, you would need to copy your assembly code to memory as a new object and run it from there to avoid any reference conflicts when detaching.

So while possible, it seems rather silly when a simple user variable seems like more than sufficient. If you don't want users accessing your list, you can use the Library Data object format. A good resource would be James Donnelly's An Introduction to HP48 System RPL and Assembly Language Programming (free PDF on hpcalc.org)