Files
2026-06-17 14:00:51 +02:00

86 lines
4.5 KiB
Plaintext

<!DOCTYPE html>
<html lang="en">
<head>
<meta name="generator" content="HTML Tidy for HTML5 for Apple macOS version 5.8.0">
<title>JMRI: Memories</title>
<!--#include virtual="/help/en/parts/Style.shtml" -->
</head>
<body>
<!--#include virtual="/help/en/parts/Header.shtml" -->
<div id="mBody">
<!--#include virtual="Sidebar.shtml" -->
<div id="mainContent">
<h1>JMRI: Memory Variables Documentation</h1>
A JMRI memory variable can hold any type of object. It's really up to user code what to put
in them, and how to manipulate them.
<h2>The Memory Variable Table</h2>
The <a href="../../package/jmri/jmrit/beantable/MemoryTable.shtml">Memory Table</a> lets you
see what Memories have been defined, and what value they currently contain. The table will
ask the contents of each Memory to display itself, so an image or icon will show as a picture
in the table; most other things will show as a string. You can type a new string value into a
Memory.
<h4>Memory Table controls</h4>
<ul>
<li>Below the Memory Table you'll find the <a href=
"../../package/jmri/jmrit/beantable/MemoryAddEdit.shtml">Add...</a> button to add new
Memories.
</li>
</ul>
<h2>Using Memories with Logix</h2>
A Logix or LogixNG can test a memory for particular contents, and set the contents of a Memory to
whatever string is needed. This lets you use a Memory as a status indicator, counter or just
about anything else you can imagine. Because of their user interface, Logix generally only
put string values into Memory Variables.
<h2>Displaying a Memory Variable on a Panel</h2>
The contents of a Memory can be displayed on a <a href=
"../../package/jmri/jmrit/display/PanelEditor.shtml">panel</a>. Usually, the Memory will try
to display its contents directly. If the contents are an icon, image or string, the contents
will be shown directly. As a special case, if the contents of the Memory are "null" (the
memory contains no object), a red X icon is displayed. This lets you see and position the
memory icon on the panel. If the Memory contains the zero-length string "", that's an object,
and it will be displayed as blank space; a little hard to spot.
<p>You can customize the appearance of text in the Memory icon via its pop-up menu.</p>
<p>You can also define a series of icons to be displayed in place of the Memory's own
contents if you'd like. For an example of how this is done, please see the <a href=
"https://jmri.org/xml/samples/MemoryIconExample.xml">sample XML file</a>. Use your browser's
"view source" command, or download that file to see how it's done. Basically, the XML browser
file has a "memoryicon" element that carries various information about where to put the icon,
whether it can be selected, etc. Within that element, you can define "memorystate" elements
that define what icon to show when the memory has a specific value:</p>
<div class="wide">
<pre style="font-family: monospace;">
&lt;memoryicon memory="IM20" defaulticon="program:resources/icons/misc/Question-black.gif"&gt;
&lt;memorystate value="9" icon="program:resources/icons/misc/Nixie/M9B.gif" /&gt;
&lt;memorystate value="8" icon="program:resources/icons/misc/Nixie/M8B.gif" /&gt;
&lt;/memoryicon&gt;
</pre>
</div>
<p>(That example has been simplified by omitting some stuff from the memoryicon element) In
the example, the two memorystate elements ensure that if the Memory contains "9" or "8",
certain images will be shown, otherwise a default black question mark icon will be shown.</p>
<p>Unfortunately, JMRI doesn't have a nice GUI tool for defining the icons displayed when
using a memory icon this way. You have to edit the XML file by hand, following one of the
examples.</p>
<h3 id="addBlock">Saving Memories to disk</h3>
<p>Memories are kept in your <em>layout configuration</em>, along with Turnouts, Sensors,
Signal Heads, etc. To store this information on disk, allowing you to <a href=
"../../package/jmri/jmrit/display/PanelMenuHelp.shtml">reload it</a> next time you run JMRI,
see <a href="../apps/LoadStoreWork.shtml">Loading and Storing Your Work</a>.
</p>
<!--#include virtual="/help/en/parts/Footer.shtml" -->
</div>
<!-- closes #mainContent-->
</div>
<!-- closes #mBody-->
<script src="/js/help.js"></script>
</body>
</html>