SAVE_EEP$  strdata, addr
Purpose To store a string strdata in the user’s definable EEPROM address addr for non-volatile storage.

strdata  - may be any string constant or string variable.
addr     - FRAM/EEPROM address (1,2,3…). Please refer to your PLC’s reference manual for the upper limit of FRAM/EEPROM space.

Examples SAVE_EEP$ A$,3
Comments: The content of A$ will be stored at string space #3 of data EEPROM
See Also LOAD_EEP$( ), GETHIGH16( ), SETHIGH16

backbutton.gif (507 bytes)  Basic to TBASIC Reference Manual

 Save_EEP$ Implementation on M+ PLC

Save_EEP allows you to save “strings” into the non-volatile data area of the PLC, which could be FRAM, FLASH, or EEPROM (legacy M-series PLCs only). This data space is divided into 40-byte chunks for string storage. I.e. regardless of the length of the string, each string storage location will occupy a fixed 40-character length. Hence if “stringdata” parameter is longer 40 characters, then only the first 40 characters will be stored in the memory space and the remaining characters will be discarded.

The string and integer data actually share the same pool of data space. However, the string spaces are allocated from the top of the data space downward, while the integer spaces are allocated from the bottom of the data space and grow upward. This implementation allows say both SAVE_EEP n, 1 and SAVE_EEP$ x$, 1 to be executed in the same program without the string and integer data writing over each other space.

However, when the addresses grow larger up to a certain point, the integer and string data space will cross path and overwrite each other’s space. It is therefore the programmer’s responsibility to check that this does not happen. Here is how:

Assume the total EEPROM space for integer data = N words (16 bit).
Total number of data EEPROM space = 2N bytes
=> Maximum number of string EEPROM space = 2N/40 (rounded down).

To determine the upper limit of one type of storage, you have to first decide how much space you want to allocate to the other type. 
 
E.g. 1:  N = 1700, and you want use the first 510 location for integer data, that means the maximum number of string space available = (1700-500)*2/40 = 59.
 
E.g. 2:  N = 7700, and you want to store 200 strings. The maximum number of integer space available = (7700*2 - 200*40)/2 = 3700.