This library was written by Fookes Software to serve as a demonstration of the varied tasks that can be performed by the Editor Clipbook. It contains various items that illustrate how certain Clip commands and functions can be used. Most of these Clips do not really provide useful functions, but they can help you understand how to create your own Clips. We recommend that you look at the Clip code and compare it with what happens when you activate it.
If you have a useful Clipbook library that you would like to share with other NoteTab users, please submit it to: <clipbook@notetab.com>. Your library will then be added to the Clipbook repository on the web.
on the web.
H=";"
H=";Launching Programs"
H="Batch example"
^!Continue This Clip will first launch the Windows calculator; once you close it, MS Wordpad will be opened. Continue?
;Launches the calculator utility and waits until the user closes it
^!ShellWait calc.exe
;Launches the Wordpad program
^!Shell Wordpad.exe ^$GetShort("^##")$
H="Shortcut example"
;Executes application associated with the shortcut
^!Prompt This Clip example will only work if you have a shortcut labeled "Explorer" pointing to Windows Explorer on your Desktop.
^!Shell c:\windows\desktop\explorer.lnk
H="Send E-Mail"
;Demonstrates the ^!EMail command
^!EMail ^?[E-mail address];^?[E-mail subject=^&]^?[Copy text from active document to E-mail body?=_Yes^=;+|No^=;]
H="Launch Document"
;Opens the current document in its associated application (for example .html file opens in default browser). A temporary copy of the document is made if it wasn't saved before using the "^**" instruction
^!Shell ^**
H=";"
H=";Updating INI options"
H="1. ProgIniSave"
;Saves current settings to the "Test.ini" file in the NoteTab program directory (default when no path is specified)
^!ProgIniSave Test.ini
H="2. ProgIniEdit"
;Check if the file "Test.ini" exists. If it does, skip the next instruction, otherwise create it and save the NoteTab settings to it
^!IfFileExist ^$GetAppPath$Test.ini Skip
;Saves current settings to the "Test.ini" file in the NoteTab program directory (default when no path is specified)
^!ProgIniSave Test.ini
;Open the "Test.ini" file in NoteTab
^!Open ^$GetAppPath$Test.ini
;Show message
^!Prompt Edit items in the Test.ini file, save the changes, and then activate on the Clip "3. ProgIniLoad" to update NoteTab option settings
H="3. ProgIniLoad"
;Update NoteTab settings with options contained in the "Test.ini" file
^!ProgIniLoad Test.ini
H=";"
H=";Scripts"
H="Perl script"
;Check if a Perl interpreter has been setup. If not, jump to the label NoPerl
^!IfFileExist ^$GetPerlExe$ Next ELSE NoPerl
;Delete the file "StdError.err" from the NoteTab program directory, if it exists
^!DeleteFile ^$GetAppPath$StdError.err
;Execute the Perl interpreter with the script contained in the Clip labeled "NumLines"
^!RunPerl Perl NumLines
;If the interpreter generated error messages, load them from the file "StdError.err"
^!IfFileExist ^$GetAppPath$StdError.err Next ELSE End
^!Open ^$GetAppPath$StdError.err
^!Prompt Perl has reported some errors!
^!GoTo End
:NoPerl
^!Prompt Cannot execute this Clip without a Perl interpreter!
H="Gawk scripts"
;Thanks to Wayne M. VanWeerthuizen for the GAWK samples used by this Clip!
;Check if a Gawk interpreter has been setup. If not, jump to the label Error
^!IfFileExist ^$GetGawkExe$ Next ELSE Error
;Prompt user for the script to use with the Gawk interpreter and save answer in a variable
^!Set %ScriptName%=^?{(T=C)Choose GAWK script to modify document==_Reverse|Add Spaces}
;Abort this procedure if the Clip wizard was cancelled by the user
^!IfCancel Exit
;Execute the Gawk interpreter with the chosen script
^!RunGawk ^%ScriptName%
^!GoTo End
:Error
^!Prompt Cannot execute this Clip without a GAWK interpreter!
H="_Reverse"
# Reverse text
BEGIN { FS = "" }
{
for (i=NF;i>0;i--) printf("%s",$i);
printf("\n");
}
H="_Add Spaces"
# Add spaces
BEGIN { FS = "" }
{
for (i=1;i<NF;i++) printf("%s ",$i);
printf("%s\n",$NF);
}
H="_Perl NumLines"
#
#† \perl\numline.pl
#
# begin
while (<>) {
$x=sprintf("%05d",$.);
print "$x $_";
}
# end
H=";"
H=";Keyboard Macros"
H="Show text statistics"
;Press key combination Alt+T, followed by the letter S, followed by a delay of 400 milliseconds to give the dialog box time to open, followed by the letter M
^!Keyboard ALT+T S &400 M
H="Open AutoExec.bat"
;Set delay of approximately 200 milliseconds between each keystroke
^!KeyboardDelay 200
;Press key combination Ctrl+O (opens the File Open dialog box), followed by the text "c:\autoexec.bat", followed by the Enter key (to close the dialog box)
^!Keyboard CTRL+O #c:\autoexec.bat# ENTER
H="Use Windows Calculator"
;The following script shows how you can send keys to another program
;Check if the calculator program is open. Jumpt to BringToFront label if found
^!IfAppOpen Calculator BringToFront ELSE Next
;Calculator program was not open, so now we launch it
^!Shell Calc.exe
;give it enough time to load (4/10th of a second)
^!Delay 4
:BringToFront
;Bring Calculator program to the front
^!FocusApp Calculator
:PressKeys
;Add all numbers from 1 to 9 and then activate the equal button with the ENTER key
;Set delay of approximately 200 milliseconds between each keystroke
^!KeyboardDelay 200
;Send keystrokes to the calculator utility
^!Keyboard #1+2+3+4+5+6+7+8+9# ENTER
H=";"
H=";Wizard Fields"
H="Remember variable"
;Show message
^!Info This Clip shows you how variables can be used in the Clip wizard and reused as default values in the dialog box's fields. The value of the variables will be inserted into the current document (unless you cancel the Clip wizard). The Clip wizard will be displayed repeatedly until you click on the Cancel button.
;Place cursor at the end of the document
^!Jump TEXT_END
:StartLoop
;Show Clip wizard with two fields. Each receives the default value contained in the variable following the label's equal sign
^!Set %MonthId%=^?[Choose a month number (1..12)=4]
;Show info window with month name corresponding to user's choice. The content of the array's indexed variable is used here
^!Info Month (#^%MonthId%) = ^%Month^%MonthId%%
H="SetArray demo 2"
;Assign semicolon-delimited values to array variable
^!SetArray %Names%=Cindy;Evelyn;Nicole
;Show content of array variable
^!Info 1. List of names:^P^P^%Names%
;Change the content of the second item in the array variable according to the user's input
^!Set %Names2%=^?{Change name #2=Kay}
;Show updated content of array variable
^!Info 2. List of names:^P^P^%Names%
H="SetArray demo 3"
;Assign all the file names chosen by the user into an array variable
^!SetArray %Files%=^?[(T=O;S=M;F="Text Files (*.txt;*.ini)|*.txt;*.ini")You can select several files]
;Copy the value representing the number of items into the Count variable. The variable at index 0 indicates the number of items in the array
^!Set %Count%=^%Files0%
;Initialize the Index variable to 0
^!Set %Index%=0
;Beginning of loop
:StartLoop
;Add one to the value contained in the variable Index
^!Inc %Index%
;End the Clip if the Index number is greater than the Count number
^!If ^%Index% > ^%Count% End
;Show the file name corresponding to the current index value. The content of the array's indexed variable is used here
^!Prompt File #^%Index% = ^%Files^%Index%%
;Jump back to the start of the loop
^!Goto StartLoop
H="SetListDelimiter"
;Define a list delimiter as two successive line breaks
^!SetListDelimiter ^p^p
;Loads all the text in the current document into the array variable. Each section of text separated by a blank line will be stored in its own indexed variable
^!SetArray %Array%=^$GetText$
;Prompt the user for a paragraph index number
^!Set %ParaIndex%=^?[Display paragraph #=4]
;Display the corresponding paragraph text in an info window
;Add one to the value contained in the Index variable
^!Inc %Row%
;End Clip if value contained in Row is greater than the value contained in MaxRow (i.e. Number of lines in document)
^!If ^%Row% > ^%MaxRow% End
;Prompt user for search criteria and store matched text position in variable
^!Set %Pos%=^$GetPosInField(^%Row%;^?[(2)Column=2];^?[(3)Whole word=_Yes^=|No^=T]^?[(4)Ignore case=_Yes^=I|No^=]^?[(5)Criteria must match...=Start of field^=S|Whole field^=W|_Any part of field^=];"^?[(1)Search criteria=America]")$
;If the value stored in Pos is greater than 0 (we have a match), jump to the next instruction otherwise return to start of loop
^!If ^%Pos% > 0 Next ELSE LoopStart
;Move the input focus to the current document
^!FocusDoc
H="Copy data column"
^!Continue This Clip will open a tab-delimited file and copy all the fields from the specified column. Continue?
;Opens file "Data.txt" in the Samples subdirectory
^!Open ^$GetSamplesPath$Data.txt
;Empty the content of the Clipboard
^!SetClipboard ^%Empty%
;Copies the line count number to a variable
^!Set %MaxRow%=^$GetLineCount$
;Initialize variable Row to 0
^!Set %Row%=0
;Prompt user for field delimiter used in document (the sample file Data.txt uses tabs)
;Add one to the value contained in the Index variable
^!Inc %Row%
;End loop if value contained in Row is greater than the value contained in MaxRow (i.e. Number of lines in document)
^!If ^%Row% > ^%MaxRow% EndLoop
;Place cursor at beginning of line
^!SetCursor ^%Row%:1
;Add field matching the user-chosen column to the Clipboard with line break
^!SetClipboard ^$GetClipboard$^$GetField(^?[(1)Column to copy=2])$^%NL%
;Jump back to the start of the loop
^!GoTo LoopStart
:EndLoop
;Paste contents of the Clipboard into a new document
^!Toolbar Paste New
H=";"
H=";Miscellaneous"
H="Help on current word"
;Copy word under cursor into a variable
^!Set %Word%=^$GetWord$
;If the variable is empty (i.e. there was no word under the cursor), jump to the label ShowInfo
^!IfTrue ^$IsEmpty(^%Word%)$ ShowInfo
;Show topic matching keyword in NoteTab Help file
^!Help "" ^%Word%
;End Clip
^!Goto End
:ShowInfo
^!Prompt First put the cursor on a word. This Clip will attempt to find a matching topic in the Help file
H="Open HTML template"
;Opens a template file for the creation of a web page
^!Open ^$GetTemplatePath$HTML.tpl
H="Get DOS output"
;Displays the output of the chosen DOS command to an info window
^!Info [L]^$GetDosOutput("^?[Dos output to display in Info window=dir c:\*.*]")$
H="Copy outline topics"
;If the current document is an outline, start the procedure. Otherwise ask whether to demonstrate the feature on the Readme.otl document, which is part of the NoteTab package
^!IfFalse ^$IsOutlineDoc$ OpenReadme
;Jump to the Start label
^!GoTo Start
:OpenReadme
;Open the Readme.otl document
^!Open ^$GetAppPath$Readme.Otl
;If there was an error while trying to open it, show message and end procedure
^!IfError Error
:Start
;Initialize variable TopicIndex to 0
^!Set %TopicIndex%=0
;Store the topics count in a variable
^!Set %TopicCount%=^$GetTopicCount$
;Empty the content of the Clipboard
^!SetClipboard ^%Empty%
:LoopStart
;Add one to the value contained in the TopicIndex variable
^!Inc %TopicIndex%
;Jump to PasteTopics label if TopicIndex is greater than TopicCount
^!If ^%TopicIndex% > ^%TopicCount% PasteTopics
;Make the outline topic that matches the value in TopicIndex active
^!SetTopicIndex ^%TopicIndex%
;Add the name of the active outline topic and a line break to the Clipboard