How to use the Javascript Code Library to Create and Insert Snippets

Description

A library of code snippets can make developing applicatons easier. Commonly used patterns, examples for APIs you don't use very often, or functions you find yourself writing over and over again can be stored in the Javascript Code Library. The Javascript Code Library is available anywhere you can use the Javascript editor.

 Storing Snippets

  1. Click the Code library icon on the Javascript editor toolbar.

  2. Highlight the code you want to add and click the Add button in the Javascript Code Library toolbar along the bottom of the dialog.

  3. If desired, specify a name for the code snippet in the Name dialog. Alpha Anywhere generates a default name using the first 30 characters of the code.

    Naming a snippet makes it easier to indentify and find later.
    Snippet names must be unique.
  4. Optionally, select the script and click the Favorite button to favorite your script.

    Favorite frequently used snippets for easier lookup.

 Inserting Snippets

  1. Click the Code library icon on the Javascript editor toolbar.

  2. Locate the code to insert. The Filter box above the snippet list can be used to locate the desired snippet. If you have organized code snippets into separate libraries, the dropdown box at the top of the dialog can be used to open other Javascript code libraries.

  3. In the Javascript editor, place the insertion pointer where the code should be pasted by clicking on the desired location.

  4. In the Javascript Code Library, double-click the snippet to insert. You can also click the Insert dictionary item into code editor button in the Javascript Code Library toolbar located along the bottom of the dialog.

 Editing Snippets and Adding the Insertion Point Placeholder

  1. Click the Code library icon on the Javascript editor toolbar.

  2. Open the code snippet you would like to edit. Select the snippet and click the View library entry button on the Javascript Code Library toolbar located along the bottom of the dialog.

  3. In the Preview dialog, you can make changes to snippets. You can also add the \ip placeholder. The \ip placeholder directs Alpha Anywhere to move the insertion pointer in the Javascript editor to this location after the code is inserted.

  4. Click the Update Library Entry button to save the changes to the script. Then, close the Preview dialog.

 Related Videos

For more information about the features in the Javascript Code Library and detailed instructions on how to use them, watch the videos below:

 Other Resources

A blog post was also written about the Javascript Code Library. You can read it here: Saving Code Snippets with the Javascript Code Library

See Also