Gosu Syntax Quick ReferenceConventions in This Document orangeCourierPlainText represents a keyword or operator that must be entered exactly as listed. blueCourierItalic represents a value supplied by the code writer. Lesson 1: Introduction to Gosu 1.1: Overview Printing to the console print ( Strings_and/or_variables ) 1.2: Statements Variables, declaring var variableName : dataType var variableName = initial_value Variables, setting value variableName = new_value Comments (single-line) // comment Comments (multiple-line) /* comment */ Statements • (no need to terminate statements with any character, such as a ";") Conditions • Gosu recognizes both AND and && • Gosu recognizes both OR and || • Gosu recognizes both NOT and ! • Keep in mind that = and == are different • variable = value // value is assigned to variable • variable == value // returns true if var equals value • To test for nulls, use: == null String concatenation value + value If/else if ( condition ) statement_or_{ block } else statement_or_{ block } Ternary operator condition ? returnValueIfTrue : returnValueIfFalse // parentheses not required around condition but often // added to improve readability Library functions gw.api.util.DateUtil.FunctionName(arguments) gw.api.util.StringUtil.FunctionName(arguments) gw.api.util.MathUtil.FunctionName(arguments) 1.3: Objects Objects, declare var objectName = new datatype() Objects, specify object's value objectName = someOtherObject objectName = entityName(objectID) Objects, referencing field on object object.fieldName Objects, referencing field on related object objectName.fkeyFieldName.fieldName Objects, referencing method on object objectName.methodName(arguments) Determining if object's field value has changed objectName.isFieldChanged("field") Retrieving original value of object's changed field objectName.getOriginalValue("field") Indirectly referencing subtype fields ("casting") (object as childSubtype).fieldOrMethod 1.4: Subtypes Testing an object's type (exactly at given subtype level) object.Subtype Testing an object's type (at or below given subtype level) object typeis Subtype Lesson 2: Arrays Array length array.length For loops (iterating through an array) for (currentObject in objectSet) { // statements that process currentObject } Adding index variable to for loops for (currentObject in objectSet index indexVar) Testing for existence of element array.hasMatch ( \ row -> condition ) Finding first element of given criteria array.firstWhere( \ row -> condition ) Finding all elements of given criteria array.where( \ row -> condition ) Adding object to array parentObject.addToArrayName(objectToAdd) parentObject.removeFromArrayName(objectToRemove) Lesson 3: Queries 3.1: Basic Queries Basic query and result set var queryObj = gw.api.database.Query.make(EntityToQuery) var resultsObj = queryObj.select() Viewing approximation of SQL queryObj.toString() 3.2: Restricted Queries Restricting a query using compare queryObj.compare("field", operator, value) 3.3: Result Sets Getting size of results resultsObj.Count Sorting results resultsObj.orderBy(\row -> row.FieldName) resultsObj.orderByDescending(\row -> row.FieldName) Querying when only one result is expected queryObj.select().AtMostOneRow 3.3: Subqueries Associating subquery to parent query parentQuery.subselect("fieldInParentQuery", operator, childQuery, "fieldInChildQuery") Lessons 4 And Beyond 4: Business Rules (There is no new syntax discussed in detail in this lesson.) 5: PCF functions Declaring PCF function function functName (inputvar : datatype) : returnType { // code to execute function return returnValue } Executing PCF function functName(inputVar) Committing data changes in current location CurrentLocation.startEditing() CurrentLocation.commit() 6: Enhancements Getters property get PropertyName() : returnType { // code to derive property, using "this" to reference root object return propertyValue } Setters property set PropertyName( parameter : dataType ) { // code to set appropriate property, using "this" to // reference root object } Functions function functionName(parameter : dataType) : returnType { // code to execute function, using "this" to reference root object return returnValue } 7: Script Parameters Referencing script parameters ScriptParameters.parameterName http://www.allinterview.com/mypanel.php?ap OR http://www.allinterview.com/search.php?q=Guidewire&company=&go=Search Please post your email for info for guidewire Documents and interview questions answers. Will give access to my drive for PC, CC and BC documents.