Incorrect CustomButtons Count?

Things you’d like to miss in the future...
Forum rules
You might want to read this if you're looking for priority service

:info: Please Include The Following Information
1) Your XYplorer Version (e.g., v28.00.0801)
2) Your Windows Version (e.g., Win 11)
3) Your Screen Scaling Percentage (e.g., 125%).

:info: Use Your Profile Or Signature
We strongly recommend adding your Windows Version and Screen Scaling Percentage to the Location field in your Profile or to your Signature. That way, you only have to type them once, and we won't have to search for that vital information.

:info: How To Attach Images
When attaching an Image, please use the Attachment tab at the bottom of your post and click "Add files".
Post Reply
kiwichick
Posts: 743
Joined: 08 Aug 2012 04:14
Location: Pahiatua, New Zealand

Incorrect CustomButtons Count?

Post by kiwichick »

Hi there, Not sure if this is a bug but I don't feel it returns the expected results.

When I no longer have a use for a custom button and I 'reset/clear' it why does it still show in XYplorer.ini CutomButton Count? So the count shows all previously created buttons rather than current buttons.

As you can see the count says 23 but there only 18 'actual' buttons - the others are 'old' buttons.

[CustomButtons]
Version=1
Count=23
1=""Deselect All|:exitnosave|0" #251; "
2=""Collapse Tree|:visualfilter|0" #1009 "
3=""Run Script|:queue|0" #754 "
4=""Close Other Tabs|:closetab|0" load CloseTabs "
5=""New Files|:qfv|0" load "NewFiles.xys"; "
6=""
7=""
8=""
9=""Run Script Again|:goprev|0" #755 "
10=""Open last closed Tab|:newtab|0" #343 "
11=""XYplorer Help|C:\PortableApps\XYplorer\XYplorer.chm|0" open "C:\PortableApps\XYplorer\XYplorer.chm"; "
12=""Copy items|:copyto|0" load "CopyTo.xys"; "
13=""Script Selector|:viewlist|0" load "<xydata>\ScriptSelector.xys"; "
14=""Add Tags selective|:tagsset|0" load TagAddSelected "
15=""Add Tags recursive|:tagsadd|0" load TagAddRecursive "
16=""Remove Tags|:tagsrmv|0" load TagRemoveCombined; "
17=""Archives|C:\Pictures\_ICONS\_Filetype Icons\_7-Zip\7-zip-logo.ico|0" load Archives; "
18=""
19=""New Folders|:newfolder|0" load NewFolders "
20=""Move To|:moveto|0" load MoveToLeftClick; load MoveToRightClick;"
21=""MoveUp|:up|0" load Moveup; "
22=""Delete|:del|0" load DeleteLeftCLick; load DeleteRightCLick;"
23=""

Is this the expected behaviour? Or am I 'resetting/clearing' the buttons incorrectly? I have tried removing the blank entries, doing a setkey command to set the count at 18, manually changing the entry to 18 but as soon as XYplorer is restarted the count goes back to 23.
Windows 10 Pro 22H2
Scaling 150%

PeterH
Posts: 2830
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: Incorrect CustomButtons Count?

Post by PeterH »

Count is the count of numbers, not the count of buttons.

If Count would be 18 the entries with greater number would be ignored.

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: Incorrect CustomButtons Count?

Post by serendipity »

kiwichick wrote:Hi there, Not sure if this is a bug but I don't feel it returns the expected results.

When I no longer have a use for a custom button and I 'reset/clear' it why does it still show in XYplorer.ini CutomButton Count? So the count shows all previously created buttons rather than current buttons.

As you can see the count says 23 but there only 18 'actual' buttons - the others are 'old' buttons.

[CustomButtons]
Version=1
Count=23
1=""Deselect All|:exitnosave|0" #251; "
2=""Collapse Tree|:visualfilter|0" #1009 "
3=""Run Script|:queue|0" #754 "
4=""Close Other Tabs|:closetab|0" load CloseTabs "
5=""New Files|:qfv|0" load "NewFiles.xys"; "
6=""
7=""
8=""
9=""Run Script Again|:goprev|0" #755 "
10=""Open last closed Tab|:newtab|0" #343 "
11=""XYplorer Help|C:\PortableApps\XYplorer\XYplorer.chm|0" open "C:\PortableApps\XYplorer\XYplorer.chm"; "
12=""Copy items|:copyto|0" load "CopyTo.xys"; "
13=""Script Selector|:viewlist|0" load "<xydata>\ScriptSelector.xys"; "
14=""Add Tags selective|:tagsset|0" load TagAddSelected "
15=""Add Tags recursive|:tagsadd|0" load TagAddRecursive "
16=""Remove Tags|:tagsrmv|0" load TagRemoveCombined; "
17=""Archives|C:\Pictures\_ICONS\_Filetype Icons\_7-Zip\7-zip-logo.ico|0" load Archives; "
18=""
19=""New Folders|:newfolder|0" load NewFolders "
20=""Move To|:moveto|0" load MoveToLeftClick; load MoveToRightClick;"
21=""MoveUp|:up|0" load Moveup; "
22=""Delete|:del|0" load DeleteLeftCLick; load DeleteRightCLick;"
23=""

Is this the expected behaviour? Or am I 'resetting/clearing' the buttons incorrectly? I have tried removing the blank entries, doing a setkey command to set the count at 18, manually changing the entry to 18 but as soon as XYplorer is restarted the count goes back to 23.
If your question was how to clean up empty entries? then:
1) remove empty entries.
2) Renumber and change count to total number of entries.
3) Save ini file and restart without saving.

kiwichick
Posts: 743
Joined: 08 Aug 2012 04:14
Location: Pahiatua, New Zealand

Re: Incorrect CustomButtons Count?

Post by kiwichick »

serendipity wrote:If your question was how to clean up empty entries?
Thanks serendipity, No, my question was
kiwichick wrote:Is this the expected behaviour?
to which the answer seems to be 'yes' :biggrin: That's fine.

So I hope I've done what you suggested and the ini file now looks like this:

[CustomButtons]
Version=1
Count=18
1=""Deselect All|:exitnosave|0" #251; "
2=""Collapse Tree|:visualfilter|0" #1009 "
3=""Run Script|:queue|0" #754 "
4=""Close Other Tabs|:closetab|0" load CloseTabs "
5=""New Files|:qfv|0" load "NewFiles.xys"; "
6=""Run Script Again|:goprev|0" #755 "
7=""Open last closed Tab|:newtab|0" #343 "
8=""XYplorer Help|C:\PortableApps\XYplorer\XYplorer.chm|0" open "C:\PortableApps\XYplorer\XYplorer.chm"; "
9=""Copy items|:copyto|0" load "CopyTo.xys"; "
10=""Script Selector|:viewlist|0" load "<xydata>\ScriptSelector.xys"; "
11=""Add Tags selective|:tagsset|0" load TagAddSelected "
12=""Add Tags recursive|:tagsadd|0" load TagAddRecursive "
13=""Remove Tags|:tagsrmv|0" load TagRemoveCombined; "
14=""Archives|C:\Pictures\_ICONS\_Filetype Icons\_7-Zip\7-zip-logo.ico|0" load Archives; "
15=""New Folders|:newfolder|0" load NewFolders "
16=""Move To|:moveto|0" load MoveToLeftClick; load MoveToRightClick;"
17=""MoveUp|:up|0" load Moveup; "
18=""Delete|:del|0" load DeleteLeftCLick; load DeleteRightCLick;"

It resets the count correctly, YAY, but now the toolbar button display has, not surprisingly, been completely rearranged because the button 'content' is now different. For example, button 15 is in the same place it was before but it's not the same button (was 'Add Tags recursive' - now 'New Folders'). Hope that make sense. Surely there must be an easier way?
Windows 10 Pro 22H2
Scaling 150%

nas8e9
Posts: 2232
Joined: 21 Jun 2008 14:50

Re: Incorrect CustomButtons Count?

Post by nas8e9 »

@kiwichick: If I understand correctly, your concern isn't about the operation of XYplorer (at least not until you manually edited XYplorer.ini and lost the button order) but about the way it stores settings. From previous discussions, I got the impression that Don prefers others to consider the config files to be a black box, at least while XYplorer itself keeps working.

The above is a slightly long-winded way of asking: why does it matter to you? 8)

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: Incorrect CustomButtons Count?

Post by serendipity »

I thought you were reporting a bug, hence my answer.
Is there something in particular you are trying to do? I don't understand.
edit: nas8e9 beat me to it, exact same concern.

kiwichick
Posts: 743
Joined: 08 Aug 2012 04:14
Location: Pahiatua, New Zealand

Re: Incorrect CustomButtons Count?

Post by kiwichick »

Thanks guys, I did say I wasn't "sure if this is a bug". I have no problem if it's not a bug but, as a newbie scripter, I'm just looking for clarity :?

It's not so much the way XY stores the settings as how it interprets them. I think it matters because when using getkey("count", "custombuttons") the count isn't technically correct - doesn't return what I would have thought were the "expected" results. Or does "count" not refer to the buttons that are 'currently being used' - to me it seems to refer to buttons that have 'ever been used'.
Windows 10 Pro 22H2
Scaling 150%

nas8e9
Posts: 2232
Joined: 21 Jun 2008 14:50

Re: Incorrect CustomButtons Count?

Post by nas8e9 »

kiwichick wrote:Thanks guys, I did say I wasn't "sure if this is a bug". I have no problem if it's not a bug but, as a newbie scripter, I'm just looking for clarity :?

It's not so much the way XY stores the settings as how it interprets them. I think it matters because when using getkey("count", "custombuttons") the count isn't technically correct - doesn't return what I would have thought were the "expected" results. Or does "count" not refer to the buttons that are 'currently being used' - to me it seems to refer to buttons that have 'ever been used'.
In practical terms and as is at the moment, count seems merely a pointer to how many lines must be parsed. The resulting (or surviving) lines form the true count.

Again, directly retrieving stuff from the config files (which is frequently useful or even the only way to do something) comes with caveats; that's not what the developer primarily designed these files for.

Edited.

kiwichick
Posts: 743
Joined: 08 Aug 2012 04:14
Location: Pahiatua, New Zealand

Re: Incorrect CustomButtons Count?

Post by kiwichick »

Thanks for clarifying that nas8e9 :biggrin:
Windows 10 Pro 22H2
Scaling 150%

PeterH
Posts: 2830
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: Incorrect CustomButtons Count?

Post by PeterH »

Said again, and yes to nas8e9: count is the highest key that will be read and interpreted.
If count is 10 and a key 11= exists, it will be ignored.

But those keys consisting of numbers are not simply numbers, but also are IDs! And those IDs will be refered "elsewhere", i.e. if you define a custom button to be shown. This is in section "General", key "Toolbar". There you find keys like "del", and keys like "ctb1". And ctb1 refers to the CustomButton with key=1.

In short: the numerical values # of ctb# correspond to the numeric keys in section CustomButtons. ctb12 refers to key=12.

Result: If you really want to "clean up", you have to "compress" the values in CustomButtons (as said before), but then you must fit the numbers of the ctb#-entries in section "General", key="Toolbar"!

kiwichick
Posts: 743
Joined: 08 Aug 2012 04:14
Location: Pahiatua, New Zealand

Re: Incorrect CustomButtons Count?

Post by kiwichick »

PeterH wrote:you must fit the numbers of the ctb#-entries in section "General", key="Toolbar"
Ah, now there's the missing piece :biggrin: But, as I said, I was only querying whether the count was 'expected behaviour' and, since it is, I'm happy just leaving it the way it is.

Thanks for taking the time to explain it, guys.
Windows 10 Pro 22H2
Scaling 150%

Post Reply