Syntax and Command Blocks

Knowing the basic syntax of any language that you choose to code in is as important as knowing how to shift gears in a car with a manual transmission. Understanding how to use a language's syntax is essential to programming in it. This section provides basic JavaScript syntax rules and command block examples to get you started programming quickly.

Syntax

Syntax in JavaScript differs from that of LotusScript or any other scripting language, but its structure is similar. The basic command line is a one-line expression followed by an optional semicolon:

document.write("The Slalom software is awesome!");

The previous command line invokes the write method of the document and closes with a semicolon. Even though the semicolon is optional, it's a good habit to pick up. It helps define the end of your command line and structures your code so that it clearer and easier to read. Multiple commands can also appear on one line as long as a semicolon is used to mark the end of the command:

document.write("Ice");document.write("Cream");

Command Blocks

Multiple lines of code can be placed inside command blocks using curly braces, { and } . Command blocks are used to group together large pieces of code into a single entity. This is useful when working with loops and defining functions.

A command block looks like this:

{ 
 document.writeln("When is it a good time to visit Louise?");
 document.writeln("Any time is a good time!");
}

Command blocks can also be embedded:

{ 
 JavaScript code goes here
 {
 More JavaScript code goes here
 }
}

Each time a command block is opened with an open curly brace ( { ), it must be closed with a closed curly brace ( } ). It is also common practice to indent each successive command block, as in the previous example. Extra spaces and tabs do not have any effect on the program when the code is run.

TIP

JavaScript is case sensitive!

 

JavaScript is also case sensitive when working with objects, properties, methods , keywords, operators, and variable names . Be watchful of your case use so that at code runtime you don't pull your hair out trying to figure out why your code isn't working. Here are some examples:

Document.writeLn("Can't use uppercase letters to call objects!"); 
document.WriteLN("Can't mix uppercase and lowercase to call methods either!");
document.writeln("This is better!");

Or:

var MyVar = "This variable name must match exactly when it's called." 
myvar = "This won't match the var above when called."
MyVar = "Call the variable exactly as you declared it or stick to lowercase!"

Part I. Introduction to Release 6

Whats New in Release 6?

The Release 6 Object Store

The Integrated Development Environment

Part II. Foundations of Application Design

Forms Design

Advanced Form Design

Designing Views

Using Shared Resources in Domino Applications

Using the Page Designer

Creating Outlines

Adding Framesets to Domino Applications

Automating Your Application with Agents

Part III. Programming Domino Applications

Using the Formula Language

Real-World Examples Using the Formula Language

Writing LotusScript for Domino Applications

Real-World LotusScript Examples

Writing JavaScript for Domino Applications

Real-World JavaScript Examples

Writing Java for Domino Applications

Real-World Java Examples

Enhancing Domino Applications for the Web

Part IV. Advanced Design Topics

Accessing Data with XML

Accessing Data with DECS and DCRs

Security and Domino Applications

Creating Workflow Applications

Analyzing Domino Applications

Part V. Appendices

Appendix A. HTML Reference

Appendix B. Domino URL Reference





Lotus Notes and Domino 6 Development
Lotus Notes and Domino 6 Development (2nd Edition)
ISBN: 0672325020
EAN: 2147483647
Year: 2005
Pages: 288
Similar book on Amazon

Flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net