Page 1 of 1

SC: Favs() - Set or retrieve favorites lists.

Posted: 17 Mar 2016 14:48
by TheQwerty
favs()
Sets or retrieves a Favorites list.

Syntax

Code: Select all

favs(type=(d|f), [items], [separator=CRLF], [action=a|p|s|d)
  • type [required]
    Specifies which favorites list.
    • d = Folders/Directories
    • f = Files
  • items [optional]
    Favorite items separated by separator.
    If missing the function just returns the current favorites of specified type.
  • separator [optional]
    Separator for list of items.
    Defaults to CRLF (line feed).
    Notes: CRLF chosen over pipe ('|') since items may contain visual filters or script.
  • action [optional]
    Action to take with the items.
    • a = Append to current list. (default)
    • p = Prepend to current list.
    • s = Set/Replace current list.
    • d = Delete from current list.
return - The list of current favorites for the specified type.

Examples

Code: Select all

text favs('f'); // return the current list of favorite files
favs('d', <curpath>); // add current path to favorite folders
favs('d', <curpath>,, 'd'); // remove current path from favorite folders
favs('f', <focitem>,, 'p'); // add focused item to top of favorite files
paperfolder('Favorites', favs('f') . <crlf> . favs('d')); // save favorite files and folders to a 'Favorites' paper folder
Change log:

Code: Select all

    + Scripting got a new function.
      Name: favs
      Action: Set or retrieve a Favorites list.
      Syntax: favs(type=(d|f), [items], [separator=CRLF], [action=a|p|s|d)
        type: [required] Specifies which favorites list.
              d = Folders/Directories
              f = Files
        items: [optional] Favorite items separated by separator.
               If missing the function just returns the current favorites.
        separator: [optional] Separator for list of items.
                  Defaults to CRLF (line feed)
        action: [optional] Action to take with the items.
                a = Append to current list. (Default)
                p = Prepend to current list.
                s = Set/Replace current list.
                d = Delete from current list.
      return: The list of current favorites for the specified type.

      Examples:
        text favs('f'); // return the current list of favorite files
        favs('d', <curpath>); // add current path to favorite folders
        favs('d', <curpath>,, 'd'); // remove current path from favorite folders
        favs('f', <focitem>,, 'p'); // add focused item to top of favorite files
        paperfolder('Favorites', favs('f') . <crlf> . favs('d'));
        // save favorite files and folders to a 'Favorites' paper folder

:whistle: :wink:

Re: SC: Favs() - Set or retrieve favorites lists.

Posted: 17 Mar 2016 20:58
by klownboy
Sounds interesting as well as useful. So theoretically with this SC Favs(), we would be able to add an executable file(s) to the list of Favorite Files or change the list depending on the circumstances and then immediately run Favorite File submenu (CID #564) all on the fly in a script. Would the result of running favs('f'); be equivalent to running #564? [Edit: I suppose not, it would return the separated list, not display it.] And of course, we could do similar actions with Favorite Folders.

Re: SC: Favs() - Set or retrieve favorites lists.

Posted: 17 Mar 2016 21:45
by TheQwerty
klownboy wrote:change the list depending on the circumstances and then immediately run Favorite File submenu (CID #564) all on the fly in a script.
It would be possible but there are some hurdles if your hope is to just modify a section of the list as opposed to all of it. Doing such may require putting full trust in managing your favorites to such a script.
klownboy wrote: Would the result of running favs('f'); be equivalent to running #564?
No... favs('f'); would do nothing at all - at least in the user's eyes - since it would just return the list of items and not assign it to any variable or use it in another function/command. Running popupmenu(favs('f',,'|')); would be closer to calling the submenu CIDs but not exact and in fact may not work at all depending on the user's favorites.

Scripts will need to keep in mind that favorites may contain all sorts of things besides just paths - including other scripts and captions.



My thoughts were more towards easing configuration and bring harmony to some otherwise disjointed features (highlighted folders, boxed branches, color filters, custom file icons, and favorite folders).

However, as I was typing the request I also had thoughts about further uses for building favorites from a catalog category (and then updating them), combine that with the other mentioned features and you can drive your color and icon configuration all from the catalog with that script. Take it a step further and you can combine it with paperfolders to "sync" favorites across devices/users.

More than anything it just opens the door to allowing us to (ab)use this feature with scripts and perhaps create new not yet known uses. ;)

Re: SC: Favs() - Set or retrieve favorites lists.

Posted: 11 Aug 2016 10:31
by Filehero
:whistle:

Any chance this could be added?

FH

Re: SC: Favs() - Set or retrieve favorites lists.

Posted: 23 Feb 2017 14:33
by admin
Finally I get round to do the irrestible stuff...

Re: SC: Favs() - Set or retrieve favorites lists.

Posted: 24 Feb 2017 08:30
by Filehero
admin wrote:Finally I get round to do the irrestible stuff...
Juhuuuuuuu! :D :D

Thanks man.

Re: SC: Favs() - Set or retrieve favorites lists.

Posted: 02 Sep 2018 13:17
by LittleBiG
Please, make the deletion in favs() a bit smarter. I have a full definition extended with caption and icon. I wish it would be enough to set only the caption to be able to delete an entry, instead of the whole text...

ADDITION: Isn't it possible to delete script entry in favorite by favs()? Because I couldn't.