Whats New in the ABL in Open Edge
What’s New in the ABL in Open. Edge 11. 6 Fernando Souza Software Architect June 2016
Agenda § Single-line Comments § XREF § ABL Enums § Object Serialization § Reflection § Rad. Form Subclasses 2
Single-line Comments § Starts with // § Any text after the // is ignored //This is a comment def var vch 1 as char. // This is another comment def var vch 2 // Simple comment as char format "x(30)“. // RUN myproc. p. 3
Agenda § Single-line Comments § XREF § ABL Enums § Object Serialization § Reflection § Rad. Form Subclasses 4
XREF § Option in the COMPILER statement § Index information for queries via SEARCH entry § Prior to 11. 6, only database tables or shared temp-tables SEARCH tt 1 ixnum TEMPTABLE WHOLE-INDEX § In 11. 6, it includes queries on non-shared temp-tables (“local”) 5
Agenda § Single-line Comments § XREF § ABL Enums § Object Serialization § Reflection § Rad. Form Subclasses 6
ABL Enums § Defined set of named values • For example, directions: North, South, East, West § Defined in a. cls file § Enforced by the compiler § Each named value has a numeric value associated with it § Cannot be extended, implement interfaces or inherit from anything explicitly § Serializable (can be passed between ABL clients and App. Server) 7
Defining an ABL Enum Type § Direction. cls Direction Progress. Lang. Enum Progress. Lang. Object ENUM Direction: DEFINE ENUM North South East West. END ENUM. 8
Defining an ABL Enum Type (Cont’d) § Colors. cls ENUM Colors: DEFINE ENUM Orange Red White Gray Grey = Gray. END ENUM. 9
Defining Values for Enum Members § Can explicitly assign numeric values for one or more members § INT 64 value ENUM Colors: DEFINE ENUM Red = 2 Blue = 4 Gray = 6 Grey = Gray. END ENUM. 10
Accessing Enums § Use type-name syntax def var e. Direction as Direction. def var my. Obj as my. Class. … e. Direction = Direction: North. RUN validate. Direction (INPUT e. Direction). my. Obj: redirect (INPUT-OUTPUT e. Direction). 11
ABL Enums - CASE Statement § Enum type for CASE and WHEN option(s) must match PROCEDURE validate. Direction: def input parameter pe. Dir as Direction. case pe. Dir: when Direction: South then … when Direction: North then. . when Direction: East then …. when Direction: West then … end case. END PROCEDURE. 12
ABL Enums - Comparisons § Enum types for operands in comparison operators must match. def var e. Color as Colors. if e. Color eq Colors: White or e. Color eq Colors: Red then. . . else if e. Color ne Colors: Black then … 13
ABL Enums – Comparisons (Cont’d) § Comparing equivalent named values def var e. Color as Colors. e. Color = Colors: Grey. <. . > // This resolves to TRUE as Grey and Gray are defined // as equivalent by the enum type if e. Color eq Colors: Gray then. 14
Methods for ABL Enums § Implicitly inherits from Progress. Lang. Enum § Methods: - Get. Value() - To. String() - Compare. To() - Equals() 15
ABL Enums - Get. Value and To. String def var e. Color as Colors. e. Color = Colors: Red. tbl. Name. int. Field = e. Color: Get. Value(). // or INT(e. Color) tbl. Name. char. Field = e. Color: To. String(). // or STRING(e. Color) 16
Getting Enum Instance from Name/Value § All ABL enums have a Get. Enum method which is strongly-typed Get. Enum(member-name as char) Get. Enum(numeric-value as int 64) def var e. Color as Colors. e. Color = Colors: Get. Enum(tbl. Name. int. Field). e. Color = Colors: Get. Enum(tbl. Name. char. Field). 17
Defining an ABL Flag Enum Type Permission Progress. Lang. Flags. Enum Progress. Lang. Object § Permissions. cls ENUM Permissions FLAGS: DEFINE ENUM None = 0 Read Write Read. Write = Read, Write Create Delete. END ENUM. 18
Methods for ABL Flag Enums § Implicitly inherits from Progress. Lang. Flags. Enum § Method: - Is. Flag. Set() § All ABL flag enum types contains the following strongly-typed methods: - Set. Flag() - Unset. Flag() - Toggle. Flag() § To. String() may return a comma-separated list of flags set 19
ABL Flag Enums : Setting Flag § Set one or more flags for a flag enum type in one of two ways: • Set. Flag() method • Bitwise OR operator def var e. Perm as Permissions. e. Perm = Permissions: Read. e. Perm = e. Perm: Set. Flag(Permissions: Write). e. Perm = e. Perm OR Permissions: Delete. 20
ABL Flag Enums: Check if Flag is Set § Check if one or more flags are set for a flag enum type in one of two ways: • Is. Flag. Set() method • Bitwise AND operator def var e. Perm as Permissions. <…> if e. Perm: Is. Flag. Set(Permissions: Read) then. . . if (e. Perm AND Permissions: Read) eq Permissions: Read then. . . 21
ABL Flag Enums: Other operations § Unset one or more flags for a flag enum type in one of two ways: • Unset. Flag() method • Bitwise NOT operator § Toggle one or more flags for a flag enum type in one of two ways: • Toggle. Flag() method • Bitwise XOR operator 22
ABL Flag Enums: Dynamic Access § DYNAMIC-ENUM ( enum-type-name, member-name-or-value) § To. Object() static method in Progress. Lang. Enum To. Object(enum-type-name, member-name) To. Object(enum-type-name, numeric-value) 23
ABL Enums: Reflection § Progress. Lang. Class provides additional methods - Get comma-separated list of enum member names Get. Enum. Names() - Get comma-separated list of enum values Get. Enum. Values() 24
. NET Enums § Support for. NET enums enhanced to provide: - Logical operators (EQ, NE, LT, LE, GT, GE) - Bitwise operators (OR, AND, XOR and NOT) - CASE statement - DYNAMIC-ENUM - Reflection support § NOTE: Progress. Util. Enum. Helper class is not necessary anymore. 25
Agenda § Single-line Comments § XREF § ABL Enums § Object Serialization § Reflection § Rad. Form Subclasses 26
Object Serialization § 11. 4 introduced object serialization via parameter passing between ABL client and App. Server § Serialization and deserialization can now be done programmatically § Formats supported : binary and JSON § Class must be marked as SERIALIZABLE § Object graph is serialized 27
Object Serialization Flow Object Instance Serializer Stream Storage 28
Stream Classes for Supporting Serialization § For serialization support: - Progress. IO. Output. Stream (abstract) Write( m. Data as memptr, offset as int 64, len as int 64) - Progress. IO. File. Output. Stream(file. Name as char) File. Output. Stream(file. Name as char, append. Mode as logical) 29
Stream Classes for Supporting Serialization (Cont’d) § For deserialization support: - Progress. IO. Input. Stream (abstract) Read( m. Data as memptr, offset as int 64, len as int 64) - Progress. IO. File. Input. Stream(file. Name as char) 30
Binary Serialization § Same rules defined for parameter passing to / from App. Server § With a few exceptions, all public, protected and private data members are serialized § Class API must match during deserialization § More efficient but may be less flexible 31
Serializing Object - Binary Format § Progress. IO. Binary. Serializer - Provides binary serialization and deserialization Serialize(object. Ref as Progress. Lang. Object, o. Stream as Progress. IO. Output. Stream) - Serialize() calls Write() method on class that inherits from Output. Stream class passing serialized data 32
Deserializing Object - Binary Format § Progress. IO. Binary. Serializer Deserialize(in. Stream as Progress. IO. Input. Stream) - Deserialize() calls Read() method on class that inherits from Input. Stream class to get the deserialized data 33
Binary Serialization Example using Progress. IO. *. def var o. Cust. BE as Customer. BE. def var bin. Serializer as Binary. Serializer. def var o. Stream as File. Output. Stream. <…> bin. Serializer = new Binary. Serializer(). o. Stream = new File. Output. Stream("o. Cust. bin"). bin. Serializer: Serialize(o. Cust. BE, o. Stream). 34
Binary Deserialization Example bin. Serializer = new Binary. Serializer(). in. Stream = new File. Input. Stream("o. Cust. bin"). o. Cust. BE = CAST(bin. Serializer: Deserialize(in. Stream), Customer. BE). 35
JSON Serialization § By default only public data members are serialized § Can specify one or more non-public data members to be serialized via new syntax § Deserialization less strict – API doesn’t have to exactly match § Common use case is to interact with external systems § Less efficient but more flexible 36
Serialization of Non-Public Data Members § SERIALIZABLE keyword added to: - DEFINE VARIABLE - DEFINE PROPERTY - DEFINE TEMP-TABLE - DEFINE DATASET DEFINE [ PRIVATE | PROTECTED | PUBLIC ] [ STATIC | ABSTRACT ] [ OVERRIDE ] [ SERIALIZABLE ] PROPERTY property-name 37
Serializing Object - JSON Format § Progress. IO. Json. Serializer - Provides serialization and deserialization in JSON format Json. Serializer (input formatted as logical) - Serialize() and Deserialize() methods 38
JSON Serialization Example using Progress. IO. *. def var o. Cust. BE as Customer. BE. def var j. Serializer as Json. Serializer. def var o. Stream as File. Output. Stream. <…> j. Serializer = new Json. Serializer(yes). o. Stream = new File. Output. Stream("o. Cust. json"). j. Serializer: Serialize(o. Cust. BE, o. Stream). 39
JSON Deserialization Example j. Serializer = new Json. Serializer(false). in. Stream = new File. Input. Stream("o. Cust. json"). o. Cust. BE = CAST(j. Serializer: Deserialize(in. Stream), Customer. BE). 40
JSON Example { "prods: version" : 1, "prods: obj. Id" : 1, “Customer. BE": { “Cust. Num": 1000, “Cust. Name": “Test", "prods: datasets": { “Dset. Details": { “TTDetails": [ { “fav. Color": “orange” } ] } } 41
Agenda § Single-line Comments § XREF § ABL Enums § Object Serialization § Reflection § Rad. Form Subclasses 42
Reflection § Used for inspecting and making decisions about execution at runtime § Progress. Lang. Class provided limited support § Release 11. 6 introduces: - Support for accessing information about the elements of a class - New built-in classes for Reflection 43
Progress. Lang. Class methods Methods Return Get. Constructors Progress. Reflect. Constructor Get. Methods Progress. Reflect. Method Get. Property Get. Properties Progress. Reflect. Property Get. Variables Progress. Reflect. Variable Get. Events Progress. Reflect. Event Get. Interfaces Progress. Lang. Class 44
Get. Methods § Returns array with information about methods of a class § Public non-static Get. Methods() 45
Get. Methods with Flags § Returns information about a method of a class based on flags § New built-in flag enum Progress. Reflect. Flags Access Mode Scope Class level Public Static Declared. Only Protected Instance Private Get. Methods(flags as Progress. Reflect. Flags) 46
Get. Methods Example USING Progress. Reflect. *. def var pcl. Obj as Progress. Lang. Class. def var meth. Flags as Flags. def var meth. Obj. Array as Method extent. plc. Obj = Progress. Lang. Class: Get. Class("my. Cls"). meth. Flags = Flags: Public OR Flags: Static. meth. Obj. Array = plc. Obj: Get. Methods(meth. Flags). 47
Get. Method § Returns information about a method of a class § Public non-static Get. Method( name as char, params as Progress. Lang. Parameter. List) plc. Obj = Progress. Lang. Class: Get. Class("my. Cls"). param. Obj = new Parameter. List(0). meth. Obj = plc. Obj: Get. Method("Process. Info", param. Obj). 48
Get. Method with Flags § Returns information about a method of a class based on flags Get. Method( name as char, flags as Progress. Reflect. Flags, params as Progress. Lang. Parameter. List) 49
Get. Method with Flags - Example § Return public static method “Process. Info” with a single logical input parameter plc. Obj = Progress. Lang. Class: Get. Class("my. Cls"). param. Obj = new Parameter. List(1). param. Obj: Set. Parameter(1, “logical”, “input”, NO). meth. Flags = Flags: Public OR Flags: Static. meth. Obj = plc. Obj: Get. Method("Process. Info", meth. Flags, param. Obj). 50
Progress. Reflect. Method Properties Methods Name Get. Parameters Num. Parameters Invoke Return. Type To. String Return. Type. Name Return. Extent Access. Mode Is. Static 51
Other Progress. Reflect Classes § Similar functionality for other types of members § Progress. Reflect. Property and Progress. Reflect. Variable - Get() and Set() § Progress. Reflect. Constructor - Invoke() - instantiate object 52
Agenda § Single-line Comments § XREF § ABL Enums § Object Serialization § Reflection § Rad. Form Subclasses 53
Rad. Form Subclasses § Telerik's UI for Win. Forms includes three form classes: - Rad. Form - Rad. Ribbon. Form - Shaped. Form 54
Rad. Form Subclasses (Cont’d) § We provide subclasses that extend Telerik’s forms: - Progress. Windows. OERad. Form - Progress. Windows. OERad. Ribbon. Form - Progress. Windows. OEShaped. Form - Progress. Windows. MDIChild. Rad. Ribbon. Form - Progress. Windows. MDIChild. Shaped. Form 55
- Slides: 56