Learning More Before You BeginEnsure you've set the right setup option in Specifying StarBasic Macro Options on page 151. This section covers basics of how to link to or insert scripts, macros, and events, just in the context of having them in your HTML page. These are advanced topics; to learn more about macros, see Macro Basics on page 961. To learn more about events, see Chapter 36, Creating and Using Forms, Controls, and Events , on page 921. What You Can Do in This SectionThis section covers how to add scripts to any document, whether by inserting them in a document so that they're run when the document is loaded, or associating them with a graphic or text link. You can also link macros and JavaScript to text or button hyperlink events. Finally, you can create controls, like a push button, and attach them to macros or events. Events are actions like moving the mouse over the hyperlink, clicking the mouse on the hyperlink, and moving the mouse away from the hyperlink. Inserting Scripts in DocumentsYou can insert JavaScript in documents. The inserted script is indicated by a small green square. To attach JavaScript to a control, such as a button; see Macro and Events Basics on page 947; to attach it to a hyperlink, see Using Macros, Scripts, and Events on page 487. Showing and Hiding Script IndicatorsTo show or hide note indicators, choose Tools > Options > HTML Document > Contents and select or deselect the Notes option. This applies to the indicator for notes, as well. Inserting a Script
Editing Scripts
Printing ScriptsThe Print Options window lets you choose whether to print document scripts and notes, and where. See page 493 for more information. Just Typing Macros in the HTML SourceOpenOffice.org macros have to be in the header of the HTML document. After you add the macro to the document, it will appear in the source text of the HTML document (in the header) with the following syntax (a "Hello World" example macro is used): <HEAD> (any additional content) <SCRIPT LANGUAGE="STARBASIC"> <!-- ' $LIBRARY: library_name ' $MODULE: module_name Sub test msgbox "Hello World" End Sub // --> </SCRIPT> </HEAD> Inserting Hyperlinks to Macros and ScriptsYou've already learned how to make text and graphics hyperlinks that will take you to a file or Web page. You can also make them run scripts, using the procedures in this section. Linking Macros and Scripts to Text or a Button
Linking Macros to GraphicsIf you've added a graphic to a document, you can use the Graphics window to make it trigger an action.
Note Most of the macro-insertion features in the program let you insert a macro from the Standard and other libraries, and from the document you're currently in, but not any other documents you've created. If you're having trouble finding the macro you want, it's probably in a separate document. You'll need to cut and paste it into a module in the Standard library, a new library, or create a module for it in your current document. |