Demo

There is already a macro for scaffolding out a for loop (Hint: It's for), so let's build one for a do-while loop.

If you're not familiar with a do-while loop, it's just like a while loop, except that the do comes before the while, so the code block executes at least once before the conditions are evaluated (whether they would evaluate to true or not). If the condition in the while expression evaluate to a truthly value, then the do block executes again and again, until the condition evaluates to a falsely value. A do-while loop generally looks something like this:

do { 
/*code that will execute at least once*/
} while(/*condition*/);

To create our own editor macro, let's follow the following steps:

  1. In the Application Navigator, head over to System Definition | Syntax Editor Macros.
  2. At the top of that list, click on the blue New button to create a new syntax editor macro.
  3. In the Name field, enter the string of text that you'd like to use to trigger the macro. Since we're writing a do-while macro, let's use the string dowhile as our macro name.
  4. In the Comments field, we'll write a description of what the macro generates. Let's enter something like A typical do-while code block, with a blank condition at the end.
    1. After we save this record, triggering the help syntax editor macro by typing help and then pressing Tab will include this help text next to the macro name.
  5. In the Text field, enter the following code. The $0 indicates where the user's cursor should land after the macro is triggered:
do { 
$0
} while(/*condition*/);

Right-click on the header, and click Save to submit the record to the database. From now on, you'll be able to type dowhile into any Script field, press Tab, and this macro will appear in the script editor!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.15.160.43