Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Web Design & Development > PHP/MySQL/Scripting

  • Print
  • + Share This
This chapter is from the book

Creating the Indent Menu Item

Before you create the Indent method, you need to think about the user interface. How will the user invoke your Indent method? The most obvious way is via an Indent menu item (Figure 4.39).

To create the Indent menu item:

  1. In the Project window, double-click the Menu icon to open the Menu Editor.

  2. Click the Edit menu.

  3. Click the blank menu item.

  4. In the Properties window, enter Indent for the Text property, and accept (or enter) EditIndent as the Name property.

  5. Close the Menu Editor.

  6. With the Code Editor open, choose Edit > New Menu Handler.

  7. In the dialog that appears, choose EditIndent from the pop-up menu, and click OK.

  8. In the browser pane of the Code Editor, click the disclosure triangle next to Menu Handlers.

  9. Click EditIndent to open the EditIndent menu handler in the editor pane.

  10. Enter this code in the EditIndent menu handler in the editor pane:

    dim Lt as string
    Lt = "<"
    HtmlField.text = Indent(HtmlField.
    → text,Lt)

You've coded the Indent menu item. When the user selects it, this code will define a variable Lt, assign to it the single character <, and replace the text in HtmlField with the result returned by the Indent method. Now you can create the Indent method.

To create the Indent method:

  1. With the Code Editor open, choose Edit > New Method.

  2. In the New Method dialog, enter Indent for the method's name.

  3. In the Parameters field, enter T as String, C as String.

  4. In the Return Type field, enter String.

  5. Click OK

You've created a method named Indent that takes two string parameters and returns a string value. From the way you call this method in the menu handler you created earlier, you can see what these parameters and return value are all about: You call Indent like this:

HtmlField.text = Indent(HtmlField.text,Lt) 

So the first parameter will be the HTML text; the second parameter will be the < character; and the value returned will be the HTML text, properly indented. Knowing this, you can write the code for the Indent method.

  • + Share This
  • 🔖 Save To Your Account