Condition to check?

Discuss and share scripts and script files...
Post Reply
timhatz
Posts: 41
Joined: 12 Dec 2008 06:21

Condition to check?

Post 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

admin
Site Admin
Posts: 60622
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Condition to check?

Post 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).

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Condition to check?

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

admin
Site Admin
Posts: 60622
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Condition to check?

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

timhatz
Posts: 41
Joined: 12 Dec 2008 06:21

Re: Condition to check?

Post 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

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: Condition to check?

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

admin
Site Admin
Posts: 60622
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Condition to check?

Post 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... :)

Post Reply