Faithlife Corporation

Business Hours

Monday – Saturday
6 AM – 6 PM PDT
Local: 1:12 AM

Automating Copy Bible Verses

Note: This article is written for advanced users and is not intended to answer basic questions about using the Copy Bible Verses tool. For help with Copy Bible Verses, see the help article in Libronix or one of these links:

Copy Bible Text without Footnotes and Citations
Include footnotes when copying
Unicode and fonts

The Copy Bible Verses dialog is easily controlled from another application using the ExecuteCommand method of the Libronix DLS Application object.

  • Calling ExecuteCommand
  • Parameter Strings
  • Copy Bible Verses Parameters
  • Examples

Calling ExecuteCommand

The ExecuteCommand method takes a string specifying the command. The general form of the command string is command|parameter1=value1|parameter2=value2. For Copy Bible Verses, the command is dialog-bar and the first parameter must be name=CopyBibleVerses. The following JavaScript code creates the Libronix DLS Application object if it doesn't already exist, then calls the ExecuteCommand method.

var objLDLS = null;
// try to get an already running Libronix DLS
try
{
    objLDLS = GetObject("", "LibronixDLS.LbxApplication");
}
catch (e)
{
}
if (objLDLS == null)
{
    // try to create a new Libronix LDLS
    try
    {
        objLDLS = new ActiveXObject( "LibronixDLS.LbxApplication" );
        objLDLS.Visible = true;
    }
    catch (e)
    {
    }
}
if (objLDLS != null)
{
    // the Libronix DLS was successfully created
    objLDLS.ExecuteCommand("dialog-bar|name=CopyBibleVerses");
} 

Parameter Strings

Parameter strings are the mechanism by which information is passed to and from dialogs and reports. Because special characters (such as |, % and =) must be escaped, using the Libronix LbxParameters object is the safe way to build parameter strings. The LbxParameters object has the ProgID Utility.LbxParameters. It supports the Value property to get and set parameters. The Render method returns a parameter string.

var objParams = new ActiveXObject("Utility.LbxParameters");
objParams.Value("") = "dialog-bar";
objParams.Value("name") = "CopyBibleVerses";
// Render() returns "dialog-bar|name=CopyBibleVerses"
objLDLS.ExecuteCommand(objParams.Render()); 

Copy Bible Verses Parameters

The Copy Bible Verses dialog supports a number of parameters to allow you to automatically copy a passage to the clipboard.

ref

The ref parameter contains the reference of the verses to copy. This can be:

  • the internal form (e.g. "bible.1.2.3-1.2.6")
  • a human readable form (e.g. "John 3:16-18")
  • a human readable form prefixed with a language code in square brackets (e.g. "[de] Jakob 1:1-3")
  • the special code *active*, which causes the Copy Bible Verses dialog to use the most recent active reference from the resources open in Libronix.

res

The res parameter specifies the internal ID of the resource from which to copy. You can find this out by holding down Alt+Ctrl+Shift and clicking a resource name in My Library. If not specified, it defaults to the last selected Bible. In LDLS 3.0a (and later), the special code *preferred* specifies that the preferred Bible (as set in Bible Tools Options) should be used.

style

This is the name of any style shown in the Style drop-down list. If not specified, it defaults to the last selected style.

target

This is either msword, openoffice, wordperfect, or other. This parameter only matters if action is set to paste.

action

The action parameter specifies what to do with the verses. It can take the following values:

 

Value Explanation
copy Copies the specifed verses to the clipboard. This is the same as clicking the Copy button in the Copy Bible verses dialog, except the settings are not saved as the defaults.
paste Copies the specified verses to the clipboard, then pastes them into the application selected by the target parameter. This is the same as clicking the Copy and Paste button, except the settings are not saved as the defaults.

 

show

The show parameter controls whether the dialog is displayed. It can take the following values:

 

Value Explanation
hide The dialog is hidden.
no The dialog's visibility is unchanged.
toggle The dialog's visibility is toggled.
yes The dialog is made visible. This is the default.

 

Examples

These examples assume that you have created an instance of LibronixDLS.LbxApplication and can reference it through the objLDLS variable.

JavaScript Example

To copy John 1:1-2 from the NASB95 with a style named "Simple Paragraphs":

var objParams = new ActiveXObject("Utility.LbxParameters");
objParams.Value("") = "dialog-bar";
objParams.Value("name") = "CopyBibleVerses";
objParams.Value("ref") = "John 1:1-2";
objParams.Value("res") = "LLS:1.0.71";
objParams.Value("style") = "Simple Paragraphs";
objParams.Value("action") = "copy";
objParams.Value("show") = "no";
objLDLS.ExecuteCommand(objParams.Render()); 


VBScript Example

To automatically paste Romans 5:8 into Microsoft Word from the KJV with a style named "Fully Formatted":

Dim objParams
Set objParams = CreateObject("Utility.LbxParameters")
objParams.Value("") = "dialog-bar"
objParams.Value("name") = "CopyBibleVerses"
objParams.Value("ref") = "Rom 5:8"
objParams.Value("res") = "LLS:1.0.3"
objParams.Value("style") = "Fully Formatted"
objParams.Value("action") = "paste"
objParams.Value("target") = "msword"
objParams.Value("show") = "no"
objLDLS.ExecuteCommand(objParams.Render)