SubsetGetElementName loop

Post Reply
MarenC
Regular Participant
Posts: 432
Joined: Sat Jun 08, 2019 9:55 am
OLAP Product: Planning Analytics
Version: Planning Analytics 2.0
Excel Version: Excel 2016

SubsetGetElementName loop

Post 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
burnstripe
Regular Participant
Posts: 226
Joined: Wed May 06, 2020 2:58 pm
OLAP Product: Planning Analytics
Version: 2.0.9
Excel Version: 2016

Re: SubsetGetElementName loop

Post 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
MarenC
Regular Participant
Posts: 432
Joined: Sat Jun 08, 2019 9:55 am
OLAP Product: Planning Analytics
Version: Planning Analytics 2.0
Excel Version: Excel 2016

Re: SubsetGetElementName loop

Post 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
Wim Gielis
MVP
Posts: 3222
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.1.5
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Re: SubsetGetElementName loop

Post 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 2680 times
Best regards,

Wim Gielis

IBM Champion 2024-2025
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
MarenC
Regular Participant
Posts: 432
Joined: Sat Jun 08, 2019 9:55 am
OLAP Product: Planning Analytics
Version: Planning Analytics 2.0
Excel Version: Excel 2016

Re: SubsetGetElementName loop

Post 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
Post Reply