Use the Syntax Editor
- Type Client Script in the Application Navigator's filter field.
- Select the System Definition > Client Scripts module.
- Select the New button
- Enter Lab 1.1 Using the Syntax Editor in the Name field.
- De-select the Active checkbox to prevent the script from running
In the Script field, enter the following text:
Code to test the Syntax Editor features - Syntax coloring - Special gharacter highlighting - Layout - And more
Convert the text to a comment
- Select all of the text
- Select the toggle comment button on the syntax editor toolbar
- In the Script field, below the commented lines, enter the following script exactly as it appears here. As you enter the script, note the syntax coloring, special character highlighting, auto-indentation and the automatic creation of closing braces and quotes.
var myString = "Hello World";
var myNum = 32;
var myArray = ["Smartphone", "Tablet", "Laptop"];
var myObj = {
property1: "first",
property2: "second",
property3: "Third"
};
for (var i=0; i<myArray.length; i++){
alert("The current value of myArray is: " + myArray[i]);
}
FURTHER INSTRUCTIONS
- Save the script by selecting the Save button on the Syntax Editor toolbar
- Turn off syntax highlighting by selecting the Toggle Syntax Editor button. What differences do you notice in the Syntax Editor?
- Use the Replace feature to change the number 2 in myObj.property2 to myObj.propertyTwo. ->to
- Select the Replace button
- Type 2 in the Replace field then press <enter> on your keyboard
- Type Two in the With field then press <enter> on your keyboard
- Select No when prompted to replace the 2 in 32
- Select Yes when prompted to replace number 2 in property2 with the word Two.
- Use the Replace All feature to change value for myObj.property3 form Third to third.
- Select Replace All button
- Type Third in the Replace field then press <enter> on your keyboard
- Type third in the With field then press <enter> on your keyboard
- Select Yes when prompted to replace Third with third
- Select Update button on the Header bar to save the script and exit the form