Page 1 of 1

Cell Type is Real weirdness

Posted: Wed Mar 04, 2020 12:58 pm
by MarenC
Hi,

I have a process with the following logic on the Prolog:

Code: Select all

vAdminCube = 'Admin Cube';

vDay = cellgets(vAdminCube, 'Actuals', 'Current Year', 'Day');
sFile='C:Path\testday.txt';

If( vDay @= '03' );
    Asciioutput(sFile, 'Test Output');
Endif;
The above errors with the message Cell Type is Real. This doesn't surprise me because vDay element is actually Simple.
Also the Asciioutput doesn't execute.

Here comes the weirdness:

If in the above code I insert the following code before vDay the cell Type is real error still happens but the Aciioutput now executes!

Code: Select all

nSerialNow = NOW;
vTimeStamp= TimSt (nSerialNow, '\Y\m\d\h\i\s');
vDay=subst(vTimeStamp,7,2);

vAdminCube = 'Admin Cube';

vDay = cellgets(vAdminCube, 'Actuals', 'Current Year', 'Day');
sFile='C:Path\testday.txt';

If( vDay @= '03' );
    Asciioutput(sFile, 'Test Output');
Endif;
So it now ignores the second vDay variable declaration. I presume this is related to the fact that you can't change the data type of a varibale in TM1 but this seems like weird behaviour.

Does anyone have an explanation as to what is going on?

Re: Cell Type is Real weirdness

Posted: Wed Mar 04, 2020 1:09 pm
by tomok
It makes perfect sense to me. In your first example trying to pull a numerical value with a CellGetS results in an error so no value is assigned to vDay and therefore the If( vDay @= '03' ); is false and nothing is written to sFile. In your second example, you are assigning a value to vDay and then trying to modify it with an invalid CellGetS statement. This doesn't work so your original assignment to vDay remains intact and the If( vDay @= '03' ); evaluates to true and the file is written.

Re: Cell Type is Real weirdness

Posted: Wed Mar 04, 2020 1:36 pm
by MarenC
Hi Tomok,

yes it makes perfect sense to me now! :D

Maren