Page 1 of 1

Condition to check?

Posted: 16 Jun 2009 20:45
by timhatz

Code: Select all

focus;
sel 1;
while(1==1) {
     sel +1;
  }
Is there a condition that can be checked, when the SEL +1; has reached the end of the list? Or do you have to know ho many items are in the list, and only process that many times?

Thanks, Tim

Re: Condition to check?

Posted: 16 Jun 2009 20:55
by admin
The current implementation is: when the end of the list is reached the last item is unselected, but the focus stays on it (focus must be on any item if there are items).

Re: Condition to check?

Posted: 16 Jun 2009 21:12
by TheQwerty
admin wrote:The current implementation is: when the end of the list is reached the last item is unselected, but the focus stays on it (focus must be on any item if there are items).
Which means you could do:

Code: Select all

focus;
sel 1;
while(Compare("<curitem>", "<focitem>") == 0) {
     sel +1;
}
It looks like you want to do something for every item currently visible, so an alternative is to use Report() or GetInfo(), and then GetToken() with a while loop that breaks when the token is empty.

Re: Condition to check?

Posted: 16 Jun 2009 21:17
by admin
TheQwerty wrote:It looks like you want to do something for every item currently visible, so an alternative is to use Report() or GetInfo(), and then GetToken() with a while loop that breaks when the token is empty.
BTW, CountToken() is on my list and will come soon... :wink:

Re: Condition to check?

Posted: 16 Jun 2009 23:19
by timhatz
TheQwerty wrote:
admin wrote:The current implementation is: when the end of the list is reached the last item is unselected, but the focus stays on it (focus must be on any item if there are items).
Which means you could do:

Code: Select all

focus;
sel 1;
while(Compare("<curitem>", "<focitem>") == 0) {
     sel +1;
}
It looks like you want to do something for every item currently visible, so an alternative is to use Report() or GetInfo(), and then GetToken() with a while loop that breaks when the token is empty.

The above while statement is what I was looking for.

Thanks, Tim

Re: Condition to check?

Posted: 13 May 2010 18:51
by Stefan
admin wrote:BTW, CountToken() is on my list and will come soon... :wink:
Bump :D

Found this thread while searching for GetToken() with negative index
which would start the search from the end.

gettoken(string, [index=1], [delimiter=" "])
If index is negative, the returned token will be the part from the index'th token from the right till end of string.

Code: Select all

$path = "<curpath>"; 
     $parent = regexreplace($path, '^.+\\([^\\]+)$', '$1');
   //$grandparent = gettoken($path, -2, "\");
 msg $parent;

Re: Condition to check?

Posted: 13 May 2010 18:53
by admin
Stefan wrote:
admin wrote:BTW, CountToken() is on my list and will come soon... :wink:
Bump :D

Found this thread while searching for GetToken() with negative index
which would start the search from the end.

gettoken(string, [index=1], [delimiter=" "])
If index is negative, the returned token will be the part from the index'th token from the right till end of string.

Code: Select all

$path = "<curpath>"; 
     $parent = regexreplace($path, '^.+\\([^\\]+)$', '$1');
   //$grandparent = gettoken($path, -2, "\");
 msg $parent;
Later... :)