|
Writing your first toolbar
script: Opening a Resource, Report or Dialog Box, or Web Site
The simplest toolbar script you can write makes use of the ExecuteCommand method of the Applicaton object.
An object is a thing which we store data about and manipulate. Objects are arranged in a tree like stucutre
with the hightest object at the top of the tree being the Application Object.
Data about an object is stored in properties. For example in the LDLS object model, the application object
has a visible property. If this property is assigned the value true you will be able to see the main application
window, if it is false the main application window will be hidden. By changing the properties of an object we can
manipulate the object.
An object can be manipulated by calling a method that acts upon the object. For example in the LDLS object
model, the application object has a method called ExecuteCommand. It tells LDLS to execute the command passed to
it by the ExecuteCommand method.
Methods are activated by an event. As a result this type of programming is sometimes called event-driven
programming. For toolbar scripts the activation event is the mouse click on the toolbar button. |
The general format of the ExecuteCommand Method is:
Application.ExecuteCommand(CommandString);
where the CommandString has the general format:
"command|parameter1=value1|parameter2=value2|parameter3=value3"
note: the number of parameters used is dependent upon the command and some parameters are optional.
The command strings you construct to use with the ExecuteMethod can be also used with the libroinxdls:
protocol
For more information on the synatax of LDLS
commands see the Libronix
DLS Object Model Reference.
Example to open a resource:
If you want to put a button on your toolbar to open a resource such as the TDNT:
Application.ExecuteCommand( "jump|res=LLS:46.10.16" );
Note:command is jump, parameter1 is res and value1 is the resource id (ie. LLS:46:10.16). You can susbstitute
the resouce id with that of any book you have in your library. You can find out a resource id by holding down Alt+Ctrl+Shift
and clicking a resource name in My Library
If you want to open a bible or commentary at a specific verse you can include the ref parameter in the command
string:
Application.ExecuteCommand( "jump|res=LLS:29.1.8|ref=[en]bible:john 3:16" );
For more information see the jump command
in the Libronix DLS Object
Model Reference.
Example to open a report:
If you want to put a button on your toolbar to open the Logos Bible Software Home Page (which Libronix treats
as being a report):
Application.ExecuteCommand("report|name=HomePageLBS");
Note: command is report, parameter1 is name, and value1 is HomePageLBS
Some additional report names you can use are:
Home Pages: HomePageLBS, rptAugsburgConcordiaHomePage, rptLockmanHomePage
Overview Books: ovbLuthersWorks, ovbNASElectronicBibleLibrary
Note: This is not a exhaustive list of reports available in Libronix
DLS but only those for which you are most likely to want to create a custom toolbar button. Please note you must
have the appropriate addins unlocked to access these reports. For more information on Luthers Works & NAS EBL follow the links.
For more information see the report command
in the Libronix DLS Object
Model Reference.
Example to open a dialog:
If you want to put a button on your toolbar to open the basic search dialog :
Application.ExecuteCommand("dialog|name=SearchBasic");
Note: command is dialog, parameter1 is name, and value1 is Search Basic
Some additional dialogs names you can use are:
Search: SearchBasic, SearchBible, SearchBDAG, SearchBibleMorph, LibronixBibleToolsCustomRanges
Notes: NotesOpen, NotesNew
WorkSpaces: FileLoadWorkspace, FileSaveWorkspace
Note: This is not a exhaustive list of dialogs available in Libronix
DLS but only those for which you are most likely to want to create a custom toolbar button. Some dialogs are not
listed because they are only meaningful when opened in the correct context. Please note you must have the appropriate
resource and addin unlocked to use the SearchBDAG dialog
For more information see the dialog command
in the Libronix DLS Object
Model Reference.
Example to open a dialog-bar:
If you want to put a button on your toolbar to open the copy bible verses tool :
Application.ExecuteCommand("dialog-bar|name=CopyBibleVerses");
Note: command is dialog-bar, parameter1 is name, and value1 is CopyBibleVerses
Some additional dialog-bar names you can use are:
Topic Browser: GoToTopic; Reference Browser: GoToReference; My Library: GoToResource;
Help: FloatingHelp; Keylink Options: ToolsDataTypeOptions
Idea: Accessing Help using the dialog-bar command ie. Application.ExecuteCommand("dialog-bar|name=FloatingHelp");
will open Help in the same manner as when you choose Help from the Libronix DLS menu. You can also access help
by opening it up as resource using the jump command. Doing this you are then able to search help like any other
resource using search dialog box. The resource id for help is LLS:1000.3.16 and for addin help the resource id
is: LLS:1000.3.24.
Note: This is not a exhaustive list of dialog-bars available in
Libronix DLS but only those for which you are most likely to want to create a custom toolbar button. Some dialog-bars
are not listed because they are only meaningful when opened in the correct context. Please note you must have the
appropriate automation addin unlocked to use the Copy Bible Verses Tool dialog
For more information see the dialog-bar command
in the Libronix DLS Object
Model Reference.
Example to open a web site:
If you want to put a button on your toolbar to open a website such as the World Wide Study Bible:
Application.ExecuteCommand( "web|url=http://www.ccel.org/wwsb|new-window=yes" );
Note:command is web, parameter1 is url and value1 is the internet hyperlink (ie. http://www.ccel.org/wwsb),
parameter2 is new-window and value2 is yes.
For more information see the web command
in the Libronix DLS Object
Model Reference.
Differences between Toolbar
Scripts and Microsoft Word VBA
Toolbar scripts are written in javascript, while Word macros are written in VB Script. Bradley Grainger has
pointed out the following differences that need to be taken into account when writing toolbar scripts:
A semicolon separates statements, not a blank line. A JavaScript statement can spread over multiple lines without
needing to use an underscore.
You must always use parentheses when calling a method, even if there are no parameters. eg.
VB: Application.Windows.Close
JS: Application.Windows.Close();
To declare a variable, use "var", not "Dim". eg.
VB: Dim myVariable
JS: var myVariable;
You don't need to use "Set". eg.
VB: Set myVariable = CreateObject("LibronixDLS.LbxApplication")
JS: myVariable = new ActiveXObject("LibronixDLS.LbxApplication");
|