Page 2 of 3

Re: snippet lab: Permanent Variables

Posted: 11 Apr 2011 12:40
by admin
DmFedorov wrote:
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: )
First you have to use the scripts contained in the button. The line perm $cb; will create a PV. E.g. press "Backup ClipboardText", then you will have a PV.

Re: snippet lab

Posted: 11 Apr 2011 13:00
by DmFedorov
admin wrote:First you have to use the scripts contained in the button. The line perm $cb; will create a PV. E.g. press "Backup ClipboardText", then you will have a PV.
Yes. Found.
Thanks

Re: snippet lab

Posted: 11 Apr 2011 15:25
by admin
In 9.90.0705 try this, and apply the new tweak ScriptRetainPVs=1 before. It's a small example of a filename collector, retained across sessions.

Code: Select all

Snip: CTB 1
  XYplorer 9.90.0705, 11.04.2011 15:23:03
Action
  NewUserButton
Name
  Filename Store
Icon
  :copypath
ScriptL
  "Add Current Filename"
    if (strlen(<curitem>) > 0 ) {
      perm $p_filenamestore;
      $p_filenamestore = $p_filenamestore<curitem><crlf>;
      status "filename added to store";
    } else {
      status "nothing selected", , "alert";
    }
  "-"
  "Edit Store..."
    $p_filenamestore = input("Edit Filename Store", , $p_filenamestore, m);
  "Copy Store to Clipboard"
    copytext $p_filenamestore;
  "-"
  "Unset Filename Store"
    unset $p_filenamestore;
    status "filename store unset";
ScriptR
  
FireClick
  1

Re: snippet lab

Posted: 11 Apr 2011 19:09
by tiago
admin wrote:
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.
By keywords you mean the codes like ":clip" and ":copypath", which is what I want? It doesn't. I right clicked the "available buttons" list and it copied a whole list after "copy all items", but no codes there too.

Re: snippet lab

Posted: 11 Apr 2011 20:45
by admin
tiago wrote:
admin wrote:
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.
By keywords you mean the codes like ":clip" and ":copypath", which is what I want? It doesn't. I right clicked the "available buttons" list and it copied a whole list after "copy all items", but no codes there too.
The codes are there to see and remember. Look up ":clip" then type :clip into your button properties. Where's the problem? :)

Re: snippet lab

Posted: 11 Apr 2011 21:00
by tiago
Following your guidance I just got the names of the buttons:
Separator
Address Bar Go
Hotlist
...
User Button #32
I'd like o have the icon codes listed either so I'd have more inbuilt icons to choose from when creating user buttons.

Re: snippet lab

Posted: 11 Apr 2011 22:38
by DmFedorov
You can see icon codes only by click on "User" button > Customize Toolbar...
You can select all buttons in Toolbar and in Ini-file (Toolbar=) you can see all codes too.

autorefresh, back, backupto, browsenetwork, calcfosi, cat, cks, clip, closetab, cofi, conf, copy, copypath, copyto, ctb, cut, del, dosbox, dp12, dpcopyto, dpmoveto, drives, exitnosave, favfiles, favs, find, findlabel, findtag, fore, fvs, goprev, hidenav, hightree, home, hotlist, labels, lasttarget, locktab, lstmgmt, minitree, moveto, mru, myco, netmap, netunmap, newfolder, newtab, nuke, openwith, panellast, panelmax, panelshow, paste, preview, previewfull, props, qfv, queue, redo, refresh, refreshsus, rename, savesett, showfolders, showhidden, showsystem, sort, steps, sticky, stop, syncscroll, tablist, tags, tagsadd, tagsfind, tagsrmv, tagsset, treeshow, udc, undo, viewdetails, viewlist, views, viewthumbs, visualfilter, zoomin, zoomout

Add:
so I'd have more inbuilt icons to choose from when creating user buttons
In Opus you can see all icons, search their names and codes, and select icons from other Files or other icon sets. Nice done. But I think it is not so important now.

Re: snippet lab

Posted: 11 Apr 2011 23:25
by tiago
Now I see what was going wrong. The right click MUST be done on a user created button and not on a stock one, those 32 which admin referred earlier. Sounds a bit strange, you have to create a button, click on it then having a list of codes to assign an icon to it. Thanks anyway to Don and you DmFedorov.

Re: snippet lab

Posted: 12 Apr 2011 09:45
by admin
tiago wrote:Now I see what was going wrong. The right click MUST be done on a user created button and not on a stock one, those 32 which admin referred earlier. Sounds a bit strange, you have to create a button, click on it then having a list of codes to assign an icon to it. Thanks anyway to Don and you DmFedorov.
Yes, a bit strange, but at least it is mentioned in the help: :wink:
Tip: You may as well re-use XYplorer's internal Toolbar icons for your own button. Simply state the toolbar icon key preceded by a colon (":") in the Icon field, e.g. :hotlist. You can find the toolbar icon keys in the Customize Toolbar dialog when you call it from the context menu of a user button.

Re: snippet lab

Posted: 13 Apr 2011 08:52
by admin
Improved version of "filename collector", now called "Item Store".
XY v9.90.0800 or later

1) Paste ::snippet; into the address bar and press ENTER. A text box will open to enter snippet.

2) And here comes the copy+paste ready snippet. I will create a new button at the right end of your toolbar.

Code: Select all

Snip: CTB 1
  XYplorer 9.90.0708, 13.04.2011 08:51:37
Action
  NewUserButton
Name
  Item Store
Icon
  :copypath
ScriptL
  "Add Selected Items"
    perm $p_filenamestore;
    $cntitems = get("countselected");
    if ($cntitems > 0) {
      $items = get("selecteditemspathnames");
      $p_filenamestore = $p_filenamestore$items<crlf>;
      status "$cntitems item(s) added to store";
    } else {
      status "nothing selected", , "alert";
    }
  "Add Focused Item"
    if (strlen(<focitem>) > 0 ) {
      perm $p_filenamestore;
      $p_filenamestore = $p_filenamestore<focitem><crlf>;
      status "1 item added to store";
    } else {
      status "nothing focused", , "alert";
    }
  "-"
  "Edit Item Store..."
    $p_filenamestore = input("Edit Item Store", , $p_filenamestore, m);
  "Copy Store to Clipboard"
    copytext $p_filenamestore;
  "-"
  "Unset Item Store"
    unset $p_filenamestore;
    status "item store unset";
ScriptR
  
FireClick
  1
3) Tip: Tick Configuration | Advanced | Remember permanent variables to retain the item collection across sessions.

Re: snippet lab

Posted: 03 May 2011 11:10
by admin
Improved version of the "Item Store".
- Added "Copy Items Here" which finally makes the whole excersice useful.
- Added a useful internal check using the new isset() function.
- Tip: If you don't get what this is all about: it's quite similar to a well-known free app called "Piky Basket".
XY v9.90.0812 or later

1) Paste ::snippet; into the address bar and press ENTER. A text box will open to enter snippet.

2) And here comes the copy+paste ready snippet. I will create a new button at the right end of your toolbar.

Code: Select all

Snip: CTB 1
  XYplorer 9.90.0812, 03.05.2011 11:11:10
Action
  NewUserButton
Name
  Item Store
Icon
  :copypath
ScriptL
  "Add Selected Items"
    perm $p_filenamestore;
    $cntitems = get("countselected");
    if ($cntitems > 0) {
      $items = get("selecteditemspathnames");
      $p_filenamestore = $p_filenamestore$items<crlf>;
      status "$cntitems item(s) added to store";
    } else {
      status "nothing selected", , "alert";
    }
  "Add Focused Item"
    if (strlen(<focitem>) > 0 ) {
      perm $p_filenamestore;
      $p_filenamestore = $p_filenamestore<focitem><crlf>;
      status "1 item added to store";
    } else {
      status "nothing focused", , "alert";
    }
  "-"
  "Copy Items Here"
    if isset($p_filenamestore) {
      $items = replace($p_filenamestore, <crlf>, "|");
      copyto <curpath>, $items;
    } else {
      status "no items in store", , "alert";
    }
  "-"
  "Edit Item Store..."
    $contents = isset($p_filenamestore)?$p_filenamestore:"";
    $p_filenamestore = input("Edit Item Store", , $contents, m);
  "Copy Store to Clipboard"
    copytext $p_filenamestore;
  "-"
  "Unset Item Store"
    unset $p_filenamestore;
    status "item store unset";
ScriptR
  
FireClick
  1
3) Tip: Tick Configuration | Advanced | Remember permanent variables to retain the item collection across sessions.

Re: snippet lab

Posted: 16 Jan 2012 12:50
by eil
as snippets are still undocumented, i have to ask here = how can i order a snippet(ScriptL section for example) to take script from .xys file, while creating a new button?

Re: snippet lab

Posted: 16 Jan 2012 13:54
by admin
eil wrote:as snippets are still undocumented, i have to ask here = how can i order a snippet(ScriptL section for example) to take script from .xys file, while creating a new button?
Right-click the Clear button in "Edit Button" and select "copy as snippet". Then study what you see. :)

Re: snippet lab

Posted: 16 Jan 2012 14:33
by eil
i seem to understand snippet syntax, but i don't know for sure if it's only possible to make snippet with coping script in body of snippet, or there is some way to direct it where to get script? something like:
Code:

Code: Select all

ScriptL
  load <xydata>\scripts\my_sc.xys

Re: snippet lab

Posted: 16 Jan 2012 14:46
by admin
eil wrote:i seem to understand snippet syntax, but i don't know for sure if it's only possible to make snippet with coping script in body of snippet, or there is some way to direct it where to get script? something like:
Code:

Code: Select all

ScriptL
  load <xydata>\scripts\my_sc.xys
Nope, not posssible.