Informer JavaScript Guide - Entrinsik
[Pages:52]Informer JavaScript Guide
?2015 Entrinsik, Inc.
Table of Contents
Table of Contents ......................................................................................................................................... 2 Chapter 1: Introduction ............................................................................................................................... 6
About Calculated Columns........................................................................................................................ 7 Template vs. Script................................................................................................................................ 7 What Is JavaScript? ............................................................................................................................... 7 Java vs. JavaScript ? Are They The Same Thing?................................................................................... 8 Informer JavaScript ............................................................................................................................... 8
Chapter 2: Objects: A Brief Introduction ..................................................................................................... 9 In This Chapter ........................................................................................................................................ 10 Introduction to Objects....................................................................................................................... 10 Interacting With Objects ..................................................................................................................... 10 Informer Objects ................................................................................................................................. 11
Chapter 3: Informer JavaScript .................................................................................................................. 12 In This Chapter ........................................................................................................................................ 13 Operators ................................................................................................................................................ 13 JavaScript Syntax..................................................................................................................................... 13 Variables ................................................................................................................................................. 14 Variable Values ................................................................................................................................... 14 Variable Names ................................................................................................................................... 14 Context Variables ................................................................................................................................ 14 Creating Script Columns.......................................................................................................................... 15 Statements .......................................................................................................................................... 16 Simple Columns................................................................................................................................... 16 Literal Values................................................................................................................................... 16 Column or Variable Value ............................................................................................................... 17 Calculation Result............................................................................................................................ 17 Column Type ................................................................................................................................... 18 Exercise ............................................................................................................................................... 18 Complex Columns ............................................................................................................................... 19 Exercise ............................................................................................................................................... 19
Page 2
Conditional Statements ...................................................................................................................... 19 If Statements................................................................................................................................... 19 Conditions ....................................................................................................................................... 21 Switch Statements .......................................................................................................................... 22
Exercise ............................................................................................................................................... 23 Controlled Loops ................................................................................................................................. 23
For Loops......................................................................................................................................... 23 While Loops..................................................................................................................................... 24 Do/While Loops .............................................................................................................................. 25 Loop Controls .................................................................................................................................. 25 Exercise ........................................................................................................................................... 26 Chapter 4: Data Types................................................................................................................................ 27 In This Chapter ........................................................................................................................................ 28 Informer Data Types ............................................................................................................................... 28 Numeric Data Type ................................................................................................................................. 28 String Data Type...................................................................................................................................... 28 String Properties, Methods & Operations .......................................................................................... 29 Length ............................................................................................................................................. 29 Concatenation................................................................................................................................. 29 Substrings........................................................................................................................................ 29 Finding a String in a String .............................................................................................................. 30 Breaking Apart a String ................................................................................................................... 30 Changing Case ................................................................................................................................. 30 Exercises.............................................................................................................................................. 31 Date Data Type........................................................................................................................................ 31 Date Methods and Operations ........................................................................................................... 31 Creating a Date Variable ................................................................................................................. 31 Changing the Date Format .............................................................................................................. 32 Getting the Components of a Date ................................................................................................. 33 Setting the Date .............................................................................................................................. 34 Comparing Dates............................................................................................................................. 34 Date Math ....................................................................................................................................... 36
Page 3
Exercises.............................................................................................................................................. 38 Array Data Type ...................................................................................................................................... 39
Creating Array Variables ..................................................................................................................... 39 Java Version 6 Arrays ...................................................................................................................... 39 Java Version 7 Arrays ...................................................................................................................... 39
Referencing Values in the Array.......................................................................................................... 40 Determining the Size of the Array....................................................................................................... 40 Stepping Through an Array ................................................................................................................. 40
Summing Up the Values in an Array ............................................................................................... 40 Creating a New Array ...................................................................................................................... 41 Sorting Arrays.................................................................................................................................. 41 Finding the Minimum and Maximum Value ................................................................................... 42 Converting Arrays to Strings ........................................................................................................... 42 Multi-dimensional Arrays................................................................................................................ 42 Exercises.............................................................................................................................................. 43 Functions................................................................................................................................................. 43 Exercises.............................................................................................................................................. 45 Appendix A: JavaScript Exercise Solutions ................................................................................................. 46 JavaScript Exercise Solutions .................................................................................................................. 47 Chapter 3............................................................................................................................................. 47 1. Calculated Column to display "Hello World" .............................................................................. 47 2. Calculated Column to display value of Company Name ............................................................. 47 3. Calculated Column of order total for each line........................................................................... 47 Switch Statements .............................................................................................................................. 47 1. "Backordered" if Quantity exceeds Units in Stock...................................................................... 47 Loops ................................................................................................................................................... 47 1. Sum of numbers 1 to 50............................................................................................................. 47 2. Sum of numbers 1 to 50, but stops when the sum reaches 50 ................................................. 48 Do While Statement........................................................................................................................ 48 While Statement ............................................................................................................................. 48 3. Calculated Column of the Odd numbers.................................................................................... 48 Chapter 4............................................................................................................................................. 49
Page 4
1. Number of Characters in the Last Name field............................................................................. 49 2. Concatenate first and last name together in lastname, firstname format ................................ 49 3. Calculated column that displays the first initial, a period, a space, and first 3 of the last name ........................................................................................................................................................ 49 4. Customer name to all upper case .............................................................................................. 49 Challenge - Last name field in upper case for odd numbered positions ........................................ 49 Dates ................................................................................................................................................... 50 1. Pull Month, Day and 4-Digit Year out of date ............................................................................ 50 2. Use the Simple Date Format to format date as 12062012 (month,day, year without delimiter) ........................................................................................................................................................ 50 3. Calculated column that displays "Late Shipment" or "On Time"............................................... 50 4. Calculated column to display number of days between order date and ship date (fulfillment date) ................................................................................................................................................ 50 Arrays .................................................................................................................................................. 51 1. Number of in an order (or number of items in an array)........................................................... 51 2. Calculated column that displays a message if one of the quantities is above 70...................... 51 3. Calculated Column that creates an array of the extended price of each line item ................... 51 4. Calculated column that adds the line extended price to give an order total ............................. 51
Page 5
Chapter 1: Introduction
Page 6
About Calculated Columns
Informer allows you to extend your reporting capabilities by adding calculated columns. Calculated columns use report data, literal values, or other data to do calculations, such as adding two column values together or concatenating first name and last name together. But that is not all they do. They are very powerful and can make your life much easier when generating reports. This class will help you understand how to write script calculated columns using JavaScript.
Template vs. Script
There are two different kinds of calculated columns in Informer: template and script. Template columns use plain text and HTML to format data. Placeholders, similar to those used in mail merge, allow you to insert column values into the results of the calculation. Template columns only work with single-value columns, and they cannot do computations or conditional statements. Script columns utilize the JavaScript language to write more complex calculated columns. You can do everything in a script column that you can with a template, as well as those things you can't. These are the columns on which this class will focus.
What Is JavaScript?
JavaScript was developed in 1995 by Netscape for use in their web-browser. The browser did not survive the browser wars, but fortunately, JavaScript is still around. It is primarily used as a client-side scripting language, meaning it is executed on the desktop and not the server. It gained popularity in the programming world when the Ajax development platform was introduced in 2005. It is supported in all major browsers.
Page 7
Java vs. JavaScript ? Are They The Same Thing?
The simple answer here is "No". They are two totally different languages, although the JavaScript syntax was influenced by Java. But that is where the similarities stop.
Java
JavaScript
Compiled to bytecode Strongly Typed Class Based Hierarchy
Interpreted at runtime Weakly Typed Prototype-based Hierarchy
Informer JavaScript
Informer JavaScript is hybridization of JavaScript. Normally, when you request a webpage, the server sends the page to the browser where JavaScript is interpreted and executed.
Browser
JavaScript
document.write("Hello World"); alert("DANGER Will Robinson!"); window.print();
With Informer, however, JavaScript is interpreted within the Informer Java application on the server, and the results are then sent to the browser for rendering.
Informer Application
JavaScript
Results
Browser
Because of this, you cannot affect any of the browser objects in the Document Object Model (DOM), but, this also means you have access to standard Java objects:
var today = new java.util.GregorianCalendar();
Page 8
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- how to return a function from another function in swift
- return function javascript example
- are callbacks in javascript return statements elan
- passing an array to and from a function or subprocedure in vb6
- java built in arrays university of san francisco
- javascript anonymous function return object
- informer javascript guide entrinsik
- chapter 16 javascript 3 functions university of cape town
- beginner s essential javascript cheat sheet websitesetup
- quiz 2 javascript florida state university
Related searches
- javascript invert array
- javascript array syntax
- javascript array to string
- javascript array update existing element
- javascript array functions
- javascript convert array to string
- javascript change array element
- javascript array variable
- javascript parse string to date
- javascript function array argument
- javascript update item in array
- javascript array of objects example