snippet lab

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

snippet lab

Post 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! :D (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.

Code: Select all

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

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

Re: snippet lab

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


BTW:
i don't want to test this here, but: would an [Copy Button] followed by an [Paste Button] work to COPY an button?

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

Re: snippet lab

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

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

Re: snippet lab

Post by serendipity »

Why does it say, "no more free user buttons available" when i have several free?

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

Re: snippet lab

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

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: snippet lab

Post 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.
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

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

snippet lab: Permanent Variables

Post 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

::snippet;

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

tiago
Posts: 589
Joined: 14 Feb 2011 21:41

Re: snippet lab

Post by tiago »

Trying the snippet trick I got "no more free user buttons available". :(
Just downloaded 9.90.0703 and tested on it.
Power-hungry user!!!

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

Re: snippet lab

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

tiago
Posts: 589
Joined: 14 Feb 2011 21:41

Re: snippet lab

Post by tiago »

"Just downloaded 9.90.0703 and tested on it."
Stock installation.
Power-hungry user!!!

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

Re: snippet lab

Post by admin »

tiago wrote:"Just downloaded 9.90.0703 and tested on it."
Stock installation.
Whoops, bug! :evil:

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

Re: snippet lab

Post by admin »

OK; fixed in v9.90.0704. (No mention in change log since feature is not existing officially.)

tiago
Posts: 589
Joined: 14 Feb 2011 21:41

Re: snippet lab

Post by tiago »

hey, cool icon that clipboard one! I'm looking everywhere but can't find a list of them. Any heading please?
Power-hungry user!!!

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

Re: snippet lab

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

DmFedorov
Posts: 680
Joined: 04 Jan 2011 16:36
Location: Germany

Re: snippet lab: Permanent Variables

Post 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! :wink: )

Post Reply