Loading ...
Sorry, an error occurred while loading the content.

Using templates with Perl scripts and Batch files

Expand Messages
  • Larry Thomas
    I have yet to write my clips for testing and running Perl scripts. I decided to take a detour to explore creating and saving new documents for the Perl
    Message 1 of 1 , Aug 30, 2000
      I have yet to write my clips for testing and running Perl scripts. I
      decided to take a detour to explore creating and saving new documents for
      the Perl scripts and batch files that I will be writing.

      As most people know, the process for saving files is to open the save
      dialog with the save button or the File|Save menu item and type in your
      file name and click ok. If you want another path other than the default,
      you have to browse or permanently change the default save folder.

      For the newest clip writers and some of the older ones who might have
      forgotten, you can create special templates in the NoteTab template folder
      that have the full path as part of the new file name and you can also set
      them up to use clipcode in creating the new document. With a full pathname
      as the name of the document, you can easily save these new documents to the
      folder in the pathname without changing the default save folder.


      I have set up a template for Perl Script as follows:


      = DocTemplate ClipCode "C:\Program Files\NoteTab
      # ^$GetDate(mmmm d, yyyy hh:mm am/pm)$
      # Lawrence R. Thomas
      # larryt@...

      Then I wrote the following clip and put a button on my clipbar:

      ---------< start clip >---------
      H="New Perl Script"
      ^!Open ^$GetTemplatePath$Perl.tpl
      ---------< end clip >-----------

      When I click the button a new document is created with the name:

      C:\Program Files\NoteTab Pro\Scripts\PerlScript01.pl

      Which contains commented lines for the date, my name, and my email address.
      I can start right in creating my script and when I am done I can click the
      save button. When I do a dialog will come up in:

      C:\Program Files\NoteTab Pro\

      The main part of the dialog will display a box with a list of the folders
      and files in that folder. At the bottom an entry box with the label "File
      Name" will contain the new document's default name with the name -
      C:\Program Files\NoteTab Pro\Scripts\PerlScript01.pl -
      selected/highlighted. Normally when you click ok, the file will be saved
      to the default folder but with the full pathname there, it will go to the
      scripts folder instead no matter what folder is displayed as the default.
      So far so good. If you want to use another name for the file other than
      the default name displayed you cannot just type it in and have it saved as
      you would normally expect. If you do, you will replace the special
      pathname and the file will be saved to the default folder. You can
      preserve the path by pressing the right cursor key which will unselect the
      file name and place the cursor on the right end of it. Then you can
      backspace over the name portion until you reach the backslash and type in
      your new file name with the same path behind it and it will save to the
      desired folder.

      I did not really care for the awkwardness of this so I experimented and
      then wrote a clip called "Quick Save" which makes this much simpler with
      just one simple wizard to click ok on or to type in a name and click ok.
      The clip uses the menu "Document|Rename" feature to rename the new document
      to what ever you select before saving it in the correct folder. I was
      worried about overwriting/replacing an existing file by accident and I have
      tested this quite a bit and so far I have not been able to get this clip to
      overwrite a file - even intentionally. It just gives me an error message
      and quits which is exactly what I want.

      As with all things, you try it at your own risk. Here it is. It works
      really well for me on new documents for as simple as it is.

      ---------< start clip >---------
      H="Quick Save"
      ;Larry Thomas <larryt@...>
      ;08/30/2000, 10:06:12 AM
      ^!Keyboard Alt+D R #^?{Enter Name=_^##^=|}# Enter
      ^!Save As "^##"
      ---------< end clip >-----------


    Your message has been successfully submitted and would be delivered to recipients shortly.