Page 1 of 1

SubsetGetElementName loop

Posted: Thu Jul 18, 2024 8:26 am
by MarenC
Hi,

would anyone have any idea why the following would enter into an infinite loop:

Code: Select all

sDimName = 'Position';
sSub = 'N_Level_Position';
sDimSize = SubsetGetSize(sDimName, sSub);
sPosition = '';

nLoopcount = 1;

WHILE( nLoopcount <= sDimSize );

    sPosition = SubsetGetElementName(sDimName,sSub,nLoopcount);​

    nLoopcount = nLoopcount +1;

END;

This runs normally when I comment out sPosition inside the loop:

Code: Select all

sDimName = 'Position';
sSub = 'N_Level_Position';
sDimSize = SubsetGetSize(sDimName, sSub);
sPosition = '';

nLoopcount = 1;

WHILE( nLoopcount <= sDimSize );

    #sPosition = SubsetGetElementName(sDimName,sSub,nLoopcount);​

    nLoopcount = nLoopcount +1;

END;
Moreover and equally baffling if I add an Asciioutput under the sPosition line within the loop I get an error when saving (equal sign not found) but if I add the Asciioutput after the nLoopcount = nLoopcount +1; line within the loop it saves ok.

Maren

Re: SubsetGetElementName loop

Posted: Thu Jul 18, 2024 9:14 am
by burnstripe
Inside the while loop was the code typed in or copied and pasted in.... Might have inserted a hidden character??

Try deleting between the while loop and retyping

Re: SubsetGetElementName loop

Posted: Thu Jul 18, 2024 9:25 am
by MarenC
Hi,

Thanks for the reply Burnstripe, that was my first thought.

I actually copied the SubsetGetElementName part from the cubewise web page as the IBM doesn't seem to be currently working. I.e. from here:

https://edu.cubewise.com/tm1-function-f ... ementname/

I did try deleting between the while loop and retyping as you suggest. I copied into notepad and back in but nothing works.

Maren

Re: SubsetGetElementName loop

Posted: Thu Jul 18, 2024 10:50 am
by Wim Gielis
When I paste the first code in Notepad++ I see this, maybe it's the cause:
char.PNG
char.PNG (62.39 KiB) Viewed 5308 times

Re: SubsetGetElementName loop

Posted: Thu Jul 18, 2024 11:18 am
by MarenC
Hi Wim,

Many thanks, this was the issue. No idea where that came from!

I thought I had deleted everything between the loop but obviously missed that little bit.
Must have been something copied from the cubewise page.

Maren