Page 1 of 3
snippet lab
Posted: 14 Sep 2010 12:09
by admin
I started some experiments with snippets, and it looks like it's working nicely. You now (from
v9.50.0005 onwards) can add new user buttons just by pasting a well-formed snippet!

(And this is about the only thing you can do for now with snippets.)
The following snippet will look for the next free user button (that's
Action: NewUserButton), then add it to the right end of the toolbar, and define it according to the snippet.
Code: Select all
Snip: CTB 1
XYplorer 9.50.0002, 13.09.2010 09:00:10
Action
NewUserButton
Name
Various Mini Trees
Icon
:minitree
ScriptL
"Just two drives|:minitree" loadtree "C:|D:";
"Just scripts|:minitree" loadtree "<xydata>\scripts";
"Tree number three|:minitree" loadtree "%programfiles%|%temp%|<xypath>";
ScriptR
FireClick
1
Now how do you get the snippet into the app? Simple: run the new undocumented SC
snippet through the address bar. It will open a text box to enter snippet.
Note that the snippet can also be passed as argument. In this case it is directly executed.
Code: Select all
$a = input("Enter Snippet", , , "m"); snippet $a;
The syntax of such a snippet should be self-explaining. The main trick to know is the
2-spaces-indent of the values, and the obligatory
Snip: CTB 1 at the very beginning of each snippet.
Happy snipping!
Re: snippet lab
Posted: 14 Sep 2010 12:48
by Stefan
Fine addition, thank you.
Is the HowTo open for discussion?
Admin> Now how do you get the snippet into the app? Simple:
I can imagine this way:
- right click on an button and choose "Paste Button"
- then 'SC snippet' is executed and if the clipboard starts with 'Snip: CTB 1' the clipboard content is pasted in
- double check this and press OK
And all this would be maybe better fit into the "Customize Toolbar" -dialog?
There we can immediately move the button to the place we want.
And there would be room for [Copy Button] and [Paste Button] too.
Happy snipping!
BTW:
i don't want to test this here, but: would an [Copy Button] followed by an [Paste Button] work to COPY an button?
Re: snippet lab
Posted: 14 Sep 2010 13:10
by admin
Yeah, there are possibilities. But currently I want to keep this in under-cover state and gather ideas. But, of course, it will come in handy already now for helping new users getting their buttons up.
Re: snippet lab
Posted: 14 Sep 2010 16:22
by serendipity
Why does it say, "no more free user buttons available" when i have several free?
Re: snippet lab
Posted: 14 Sep 2010 16:59
by admin
serendipity wrote:Why does it say, "no more free user buttons available" when i have several free?
Ah, that's because of a now fixed minor bug. When you open your INI you will see that the "free" ones actually have "||0" instead of nada. If you remove this "||0" they are recognized as free. Next version will do that for you.
Re: snippet lab
Posted: 18 Oct 2010 21:35
by SkyFrontier
admin wrote:serendipity wrote:Why does it say, "no more free user buttons available" when i have several free?
Ah, that's because of a now fixed minor bug. When you open your INI you will see that the "free" ones actually have "||0" instead of nada. If you remove this "||0" they are recognized as free. Next version will do that for you.
Same problem here.
Testing with the
file-based favorites thing.
snippet lab: Permanent Variables
Posted: 08 Apr 2011 09:04
by admin
You need at least v9.90.0701 for the following.
To illustrate the greatness of the new
Permanent Variables, here's a snippet that will create a new toolbar button at the right end of your current toolbar. The button can backup and restore text from/to the clipboard. It's just a modest example.
Run this command through the Address Bar, then paste the snippet below into the edit box.
Code: Select all
Snip: CTB 1
XYplorer 9.90.0702, 08.04.2011 08:57:35
Action
NewUserButton
Name
Clipboard Store
Icon
:clip
ScriptL
"Backup Clipboard Text (New)"
perm $cb; $cb = <clipboard>;
"Backup Clipboard Text (Add)"
perm $cb; $cb = $cb<crlf><clipboard>;
"-"
"Restore Clipboard Text"
copytext $cb;
"-"
"Unset Clipboard Store"
unset $cb;
ScriptR
FireClick
1
Re: snippet lab
Posted: 09 Apr 2011 21:50
by tiago
Trying the snippet trick I got "no more free user buttons available".

Just downloaded 9.90.0703 and tested on it.
Re: snippet lab
Posted: 10 Apr 2011 08:52
by admin
tiago wrote:Trying the snippet trick I got "no more free user buttons available".

Just downloaded 9.90.0703 and tested on it.
32 is the max number. Remove one that you don't need anymore.
Re: snippet lab
Posted: 10 Apr 2011 14:30
by tiago
"Just downloaded 9.90.0703 and tested on it."
Stock installation.
Re: snippet lab
Posted: 10 Apr 2011 17:36
by admin
tiago wrote:"Just downloaded 9.90.0703 and tested on it."
Stock installation.
Whoops, bug!

Re: snippet lab
Posted: 10 Apr 2011 18:52
by admin
OK; fixed in v9.90.0704. (No mention in change log since feature is not existing officially.)
Re: snippet lab
Posted: 11 Apr 2011 00:55
by tiago
hey, cool icon that clipboard one! I'm looking everywhere but can't find a list of them. Any heading please?
Re: snippet lab
Posted: 11 Apr 2011 08:05
by admin
tiago wrote:hey, cool icon that clipboard one! I'm looking everywhere but can't find a list of them. Any heading please?
Right-click the button, click "Customize Toolbar...", voila, a list of all icons with keywords in square brackets.
Re: snippet lab: Permanent Variables
Posted: 11 Apr 2011 11:53
by DmFedorov
admin wrote:
To illustrate the greatness of the new Permanent Variables, here's a snippet that will create a new toolbar button at the right end of your current toolbar. The button can backup and restore text from/to the clipboard. It's just a modest example.
How can I see Permanent variables from the menu Scripting > List Permanent Variables?
And where is these Permanent variables in your code (if code illustrates their work)?
(I have thought that during the execution [::snippet;] or after that I will see these variables. They are permanent!

)