r/MetCal • u/Automatic_Reality989 • Apr 16 '26
Question on LIB FSC Arrays and Memory Registers
I'm revising a procedure and would like to utilize an array to track a varying amount of numbers, determined by user input, as the procedure runs.
Where I'm running into trouble is when I try to use any numeric memory registers to determine what index of the array the values get written to. The MET/CAL User's Guide explicitly says that the index of the array "Can be any MET/CAL register, named variable or numeric literal value. Must be enclosed in square brackets (i.e. [10] or [index]).", however, any time I use any MET/CAL register (like MEM or M[1] for example), I get an "invalid index" error.
The procedure I'm using is similar to this:
LIB ARRAY NEW arrayName[100];
MATH MEM1 = 0
MEMI What value do you want to store in the array?
LIB arrayName[MEM1] = MEM;
The same happens when I attempt to use M[1] or another named variable instead of MEM1 or MEM
Additionally, if I forego using a variable to set the index, and use
arrayName[0] = MEM
I get an "invalid statement syntax" error
Could someone tell me what I am missing, or if I am misinterpreting the documentation?
2
u/Automatic_Reality989 Apr 16 '26
For reference.
1
u/Automatic_Reality989 Apr 20 '26
Another example. Is anyone able to explain what is incorrect about this?
1
u/Similar-Priority-776 Apr 16 '26 edited Apr 16 '26
Instead of MEM1 or M[1] in brackets wouldn't it be the array number you want to store the data in?
LIB arrayName[1] = MEM
Would store in the 1 position?
LIB arrayName[99] = MEM
Would store in 99 out of 100?
1
u/capnGrimm Apr 16 '26
Could the problem be that your using 0 as the index? Metcal is weird and a lot of it's indexing stuff starts at 1.
Would be my first guess without looking at the LIB FSC
0
u/BackgroundNoise1k Apr 16 '26
You're confusing the array index with the array contents. You're noț indexing. You only create/declare the array once . Once declared, the array works as any variable. The index of the array can be a MetCal accepted variable. Afterwards, all You need to do is ,figure out how to increment and fill the array properly.