Page 1 of 1

Tab ID vs. Tab Index [Solved]

Posted: 11 Mar 2022 04:46
by John_C

Code: Select all

$index = tab("get", "index");
$id = tab("get");
Are there cases when there is a difference between them?

Or id is simply a modern, better name for index?

Re: Tab ID vs. Tab Index

Posted: 11 Mar 2022 04:53
by jupe
Probz easier if you just read the help file where it is explained, (or run 2min worth of tests yourself)
"ID":
returns the ID of the tab referred to by index (or by ID). The ID is a unique and stable
identifier for a tab that never changes as long as the tab lives. The smallest possible ID
is 1.
"index":
returns the index of the tab referred to by ID (or by index). The smallest possible index
is 1 and refers to the leftmost tab.


index
Refers to a tab by its position, first tab = 1
Defaults to the current tab. See also individual descriptions above under each operation
.
ID
Unique and stable identifier for a tab that never changes as long as the tab lives. Does
not change if tab is moved.
The smallest possible ID is 1.
So no, not the same. ID stays the same no matter the tabs index, index can change if you drag the tab left or right for example.

Re: Tab ID vs. Tab Index

Posted: 11 Mar 2022 08:48
by John_C
jupe, but I have read the help and I have tried to drag the tabs before asking. And yes, they work the same for me on my XY 20.30 and on the latest XY 20.90.0100. The OS is Win7.

Step by step:

1. Open two tabs, e.g. the 1st is C:\Windows and the second is C:\Program Files
2. Run msg tab("get"); in each tab. The tab with Windows will return 1. The tab with Program Files will return 2.
3. Drag the second tab to the left, so that now the first tab is C:\Program Files and the second is C:\Windows
4. Repeat the second step. The tab with Program Files will return 1. The tab with Windows will return 2.

EDIT: Ok, sorry. For some reason, I assumed that tab("get"); is the same as tab("get", "id");

Re: Tab ID vs. Tab Index

Posted: 11 Mar 2022 08:51
by jupe
Your example is using id not index, try reading the help properly, or even my post you just replied to, assumptions aren't necessary.