Page 1 of 1

Incorrect CustomButtons Count?

Posted: 01 Oct 2012 00:18
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.

Re: Incorrect CustomButtons Count?

Posted: 01 Oct 2012 00:35
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.

Re: Incorrect CustomButtons Count?

Posted: 01 Oct 2012 00:44
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.

Re: Incorrect CustomButtons Count?

Posted: 01 Oct 2012 01:37
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?

Re: Incorrect CustomButtons Count?

Posted: 01 Oct 2012 02:00
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)

Re: Incorrect CustomButtons Count?

Posted: 01 Oct 2012 02:01
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.

Re: Incorrect CustomButtons Count?

Posted: 01 Oct 2012 03:06
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'.

Re: Incorrect CustomButtons Count?

Posted: 01 Oct 2012 03:33
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.

Re: Incorrect CustomButtons Count?

Posted: 01 Oct 2012 04:50
by kiwichick
Thanks for clarifying that nas8e9 :biggrin:

Re: Incorrect CustomButtons Count?

Posted: 01 Oct 2012 10:40
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"!

Re: Incorrect CustomButtons Count?

Posted: 01 Oct 2012 23:02
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.