MCP Commands - Memory Bank

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > Internet and Network > MCP. - MCP (Model-Context Protocol) server operations > Memory Bank - Commands for storing and recalling data >

MCP Commands - Memory Bank

MEM.EXS - Check if Memory Key Exists

PreviousTopNext


MiniRobot Language (MRL) - MCP Memory Bank Commands

 

MEM.EXS / MEM.Exists

Check if a Memory Key Exists

 

Purpose

 

The MEM.EXS command checks whether a specified key exists in the MCP Memory Bank. This is useful for verifying if data has been previously stored before attempting to recall or modify it. The command returns 1 (TRUE) if the key exists, or 0 (FALSE) if it does not.

 

This command is particularly useful when:

• Checking if cached data is available

• Verifying if a previous computation result exists

• Avoiding errors from attempting to recall non-existent keys

• Implementing conditional logic based on memory state

 

Syntax

 

MEM.EXS|$$KEY|$$RETURN_VAR

 

MEM.Exists|$$KEY|$$RETURN_VAR

 

Parameters

 

$$KEY - The memory key to check for existence. This is the same key used with MEM.STO or MEM.S to store data.

 

$$RETURN_VAR - The variable that will receive the result (1 if key exists, 0 if not).

 

Return Value

 

1 - The key exists in the memory bank (can be recalled with MEM.RCL)

0 - The key does not exist (MEM.RCL would return empty)

 

Examples

 

' Example 1: Basic existence check

MEM.EXS|$$CachedResult|$$Exists

IVV.$$Exists!0

MEM.RCL|$$CachedResult|$$Data

PRT.Using cached data: $$Data

ELS.

PRT.No cache found, computing...

' ... compute and store result ...

EIF.

 

' Example 2: Check before deleting

MEM.EXS|$$TempKey|$$HasTemp

IVV.$$HasTemp!0

MEM.DEL|$$TempKey

PRT.Temporary data cleaned up

ELS.

PRT.No temporary data to clean

EIF.

 

' Example 3: Conditional initialization

MEM.EXS|$$Counter|$$HasCounter

IVV.$$HasCounter!0

MEM.S|$$Counter|1

PRT.Counter initialized to 1

EIF.

 

Remarks

 

The MEM.EXS command requires the Memory Bank feature to be enabled in the MCP server configuration. If the feature is disabled, the command will return 0 (FALSE) and log a warning.

 

The command checks for keys in the standard MCP memory store, which includes both temporary (TEMP) and permanent (PERM) storage. The persistence type does not affect the existence check.

 

MEM.EXS and MEM.Exists are aliases for the same command. You can use either form.

 

Error Conditions

 

The command will fail with a parameter error if:

• The key parameter is missing

• The return variable parameter is missing

• Too many parameters are provided

 

See also:

 

MEM.STO - Store Value in Memory

MEM.RCL - Recall Value from Memory

MEM.DEL - Delete Memory Key

MEM.LST - List Memory Keys

Memory Bank Overview