[Show/Hide Left Column]

s_ImportingF9Snippets

Importing F9 Snippets


Note: This page is already obselete with version 1.60rc19 which introduced an inbuilt way to handle item description. A new page will be written soon. This page will be kept for older version of ZTreeWin and for archiving reasons only.


Thanks to the new ZAM feature, sharing collections of scripts is now easier than ever.

Importing and exporting a single F9 script (a snippet) is also very easy using cut and paste, for instance from this Wiki to F9 editor or vice-versa. Importing can also be done from a file via the F9,Alt-E,Load features. However, both technics does import only the code part, and not the item description.

Some would say that item description should be let to user preference, but I believe it should also be imported as default description.

Here's a technic to import a complete snippet from a text file. I developped this technic with the idea of creating a collection of F9 snippet files that could be easily exchanged through email or zip files.

1. Standard *.F9 snippet file

A file that contains a snippet should follow the structure proposed in the Script standards page. The text file as three parts:
Line 1:           Single-line item description
Line 2 to n:      Informative headers
Line n+1 to end:  Code itself

The file is saved under any name, it doesn't matter. But the *.F9 extension is proposed as a convention (apparently, this extension is also available on FileExt(external link)).

2. Importing snippet from standard *.F9 file

The following is a macro that imports a *.F9 snippet. Cut and paste the following code and save it under a new text file with name Import F9.ZTM (or whatever you like) in your ZTreeWin directory. Alternatively, you can downloaded it by clicking here.
;; Purpose:         Import current F9 snippets
;; Author:          Laurent Duchastel
;; Original author: n/a
;; Contributors:    n/a
;; Version:         2007-02-22, v1.0
;; ZTW ver:         1.60rc18
;; OS version:      WinXP FR
;; Requires:        n/a
;; Usage:           You must first position in F9 where you want the snippet
;;                  to be inserted. Then in FW, position over the snippet.
;; Note1:           F9 snippet is a text file which first line must absolutely
;;                  contains item description used in F9 tree
;; Note2:           To speed up multiple importation process, you can run the macro once
;;                  and then assign a shortcut in F12 history, for instance 9.
;;                  In this example, only F12,Alt-9 will launch the macro.
;; History:         n/a
CTRL_INS,N,
;Insert filename in clipboard
F9,ALT_A,RET,ALT_E,l,SH_INS,RET,
;Add a new empty item then load snippet from file
RET,CTRL_X,ESC,d,
;Insert first line in memory then delete it
r,CTRL_V,RET,ESC,
;Paste description

To use it, you must open F9 and position highlighted menu line were you want to import the snippet. Then close the F9 menu, position ZTreeWin over the *.F9 file to import and launch the macro by typing F12, @Import F9.ZTM,Enter. That's it. The snippet as been imported with proposed item description.

Tip: Once @Import F9.ZTM has been run at least once, it will be in the F12 history. You should make the entry sticky and assign a shortcut. For instance, assign the number 9 as the shortcut. Later, use only F12,Alt-9 to launch the macro over a highlighted *.f9 file. Much faster.

3. Exporting snippet to a standard *.F9 file

Unfortunately, you still have to export a snippet to a standard *.F9 file manually. I did not find a way to automate this. There is two major challenges to overcome: 1) Insert item description in first line of *.F9 file, 2) Saving the file without being able to check if proposed filename is valid.

ZEP for F9 Import/Export

However, what would be really helpful to avoid all this process and contribute to easier sharing of single snippet with item description is the same technic used with ZAM, that is a built-in Open command. This requires coding by Kim.

1. Exporting
Exporting to a standard F9 file would require only a slight modification of the actual F9,Alt-E,W command to include the item description in the first line.

2. Importing
Importing a standard F9 file would be done by positionning ZTreeWin over a standard F9 file and opening it. The logic would be:
  1. Proceed if the file has a *.F9 extension
  2. Check if it's a standard F9 file (text file with text on first line)
  3. Open F9 menu and let the user specify where to insert the snippet (similar browsing as F2 in FW).
  4. Press enter, import the snippet and let F9 menu opened or close it, based on CO configuration
At any time, Esc could cancel the importation process.

Contributors to this page: laurent .
Page last modified on Sunday 25 of February, 2007 11:15:34 EST by laurent.