While function troubleshooting

Could someone chime in on this one ?

Below you find my code, I've tried to add clear comments.
I've tried different approaches, without luck but must be missing something in my first attempts to try this function.

Also attached is a screenshot from dataviewer and Context.

 While ( 

	[
	~i = 1 ;  //index or counter
	~trshld = SYSid_zzk_ArCo~kunstenaar ;  //in this particular case 119, just a hard coded primary key derived from a custom function
	~value = "" ;  //declaring this var for later use
	~id = "" //declaring this var for later use
	] ;

	~id = ~trshld ;  //if ~id equals to the ~trshld, the loop must stop

	[
	~id = GetNthRecord ( SYS~::__id ; ~i ) ;  //Set ~id based on ~i, should be replaced when looping.
	~value = GetNthRecord ( SYS~::Value ; ~i ) ;  //Set ~value based on ~i, should be replaced when looping
	~i = ~i + 1 //raise index so loop looks for next record
	] ;

	~value //output

)

first the ~trshld declaration looks wrong because it doesn't refer on first init part to a variable nor a ligit field "::" missing or "$" missing.

second your while condition explains the case where it executes the while body statement and not as you state the stop condition ..

2 Likes

Inverting the condition solved the issue.

Considering the declaration of the variable. As you can see on my screenshot, this is a custom function. Filled with a hardcoded primary key, so no issues here.

Inverting the condition was the way to go. Thanks a heap for pointing me in the right direction.

1 Like

you got me - wasn't thinking of Custom Functions yet - especially not a void one .. thanks for explaining!