Topic: DMD0113

Help File Version: 2.10.0.636

REF - Read Value Indirectly


This instruction can only be used in the Expression parameter of the Calculate Expression (MATH) instruction.

 

The Read Value Indirectly (REF) math function returns the value of the specified bit or numerical element. The element is referenced by a memory block number and the offset of the desired element within that block. This method of indirectly addressing memory locations is often called the "pointer" method.

 

Result is the memory location to store the result of the calculation. This can be any writable numeric location.

 

The Expression parameter consists of all the text between the bounding parentheses. Any expression parameter can be a constant value, a bit or numeric memory location, an arithmetic expression, and / or mathematical function or other expressions up to a maximum of 1024 characters. Expressions can be nested, so use of parentheses is recommended to ensure proper evaluation order.

 


Parameters:

Note: Use the F9 key or click the 'three dot box' at the right edge of the parameter field to open the Default Element Selection Tool (the Element Picker or the Element Browser) or use the Down-Arrow key (Auto-Complete) on any parameter field to see a complete list of the memory locations that are valid for that parameter of the instruction.

 

The first parameter is the source memory block number from the list of memory block numbers shown in the Memory Configuration tab of the System Configuration dialog. This must reference a Bit or Numeric data block, structure data blocks are not valid. If the first parameter (Block Number) is not a valid memory block number, $IndexError (ST129) will be ON.

 

The second parameter is the offset within the selected memory block. This can be any constant value from 0 to 65535 or any readable numeric location containing a value within that range. If the second parameter (Offset) exceeds the size of the selected data block, $IndexError (ST129) will be ON.

 


Memory Block Numbers:

The following image shows the default layout of the predefined Bit and Numeric memory block numbers. Any user created blocks will be assigned a unique block number when they are created. These block numbers can be seen in the Memory Configuration page of the System Configuration dialog.

 

 


See Also:

REF - Read Value Indirectly

 

REFWRITE - Write Value Indirectly

 


Related Topics:

MATH - Calculate Expression

 


Rung Example: