Synon 2E Data Types
Synon 2E Data Types
Agenda
Data Type Definition Screens External Length Calculation Program Mapping Functions Additional Mapping Parameters Examples
Field Attributes
._______________________________________________________________________________. | *ADD Op: SYNDSNR WISRMT2S1 1/26/92 8:52:50| | EDIT FIELD ATTRIBUTE. Windsor, Inc. WISDMMDL | | Field attribute. . . . : CC# | | Text . . . . . . . . . : Credit Card Number | | Right hand side text . : | | Allow user Initial Allowed Override | | entry value values value | | Internal data type . . : O (I,O,H) A (A,P,S,B,F) | | Internal length. . . . : O (I,O,H) 16 | | External data type . . : A (A,S) | | External length. . . . : O (I,O,H) 19 (Output| | Keyboard shift . . . . : O (I,O,H) M XANWIDM (XANWIDM/NSYID| | Lowercase. . . . . . . : H (I,O,H) (Y,' ') | | Check valid system name: H (I,O,H) (Y,' ') | | Mandatory fill . . . . : O (I,O,H) (Y,' ') | | Modulus check 10/11. . : H (I,O,H) (10,11,' ') | | | | | | Allow value mapping. . : N (Y,N) Y (Y,' ') | | Int/ext len conv. . : (I,C,V,' ') | | Int/ext function. . : Convert Credit Card # | | Ext/int function. . : Check Credit Card # | | | 2
YxxxLENR1C Parameters
Input Parameters
Object attribute Keyboard shift Value mapped status Internal data type Internal length Internal no. of integers Internal no. of decimals External data type CDE CDE CDE CDE NBR NBR NBR CDE NBR NBR NBR 3 1 1 1 5.0 2.0 1.0 1 5.0 2.0 1.0
Output Parameters
External length External no. of integers External no. of decimals
Mapping Functions
External/Internal always invoked when field may be entered on screen Internal/External always invoked prior to displaying or printing value When re-displaying on error, Internal/External is invoked and must be capable of dealing with data in error. May have external value, internal value, and mapping data parameters
If value-mapping, convert from external to internal format (this must be done even if there is an error) If data loss occurs on mapping and there is an error, pass error indicator in internal format rather than mapping. Consider EXCUSRSRC if a routine is large and called often, particularly in the same function. This will reduce generated code.
Internal Parameter
Output or Both (usually output; use both if constructing a value) Define as NBR, CDE, TXT or data type Always second parameter if used Not required if function only validates (no value mapping)
Internal Parameter
Input or Both (usually Input) Define as NBR, CDE, TXT or data type Always second parameter if used Not required if function only validates (no value mapping)
11
DT8 Attributes
._______________________________________________________________________________. | *CHANGE Op: SYNVG WISDM395A 2/10/92 13:09:17| | EDIT FIELD ATTRIBUTE. Test1 Model | | Field attribute. . . . : DT8 | | Text . . . . . . . . . : 8-Digit Date: int-CCYYMMDD ext-MMDDCCYY | | Right hand side text . : | | Allow user Initial Allowed Override | | entry value values value | | Internal data type . . : O (I,O,H) P (A,P,S,B,F) | | Internal length. . . . : O (I,O,H) 8.0 | | External data type . . : S (A,S) | | External length. . . . : O (I,O,H) 8.0 (Output| | Keyboard shift . . . . : I (I,O,H) DYN (XANWIDM/NSYID| | Lowercase. . . . . . . : H (I,O,H) (Y,' ') | | Check valid system name: H (I,O,H) (Y,' ') | | Mandatory fill . . . . : H (I,O,H) (Y,' ') | | Modulus check 10/11. . : H (I,O,H) (10,11,' ') | | | | | | Allow value mapping. . : N (Y,N) Y (Y,' ') | | Int/ext len conv. . : I (I,C,V,' ') | | Int/ext function. . : Convert DT8 | | Ext/int function. . : Check DT8 | | | | F3=Exit F11=Delete | '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' ** Note the setting of Value mapping 12
1 to 12 1 1 1 1 to to to to 29 28 31 30
NBR
2.0
1 > Check DT8 1 .->>1 . > Check DT8 >>1 . .->>1 . . * Initialize Return Code >>1 . . PGM.*Return code = CND.*Normal ** Note use of *Return code >>1 . . >>1 . . * First we will convert the date from external to internal form. >>1 . . This is necessary because the internal form is converted to >>1 . . the external form when the screen is redisplayed, regardless >>1 . . of any errors. >>1 . . * After we have converted the date, we will validate it. Each >>1 . . portion of the date (CC, YY, MM, DD) is validated. Any error >>1 . . will result in an error message signifying an invalid 8-digit >>1 . . date. ** This would be the general flow of a validation program unless circumstances dictate otherwise >>1 . . >>1 . . > Exit with no error if incoming date is zero. >>1 . . .-CASE >>1 . . -PAR.$DT8 External is Equal to Zero >>1 . . PAR.$DT8 Internal = CON.*ZERO >>1 . . <-- *QUIT >>1 . . '-ENDCASE ** Remember to code for optional fields. The validation will still be called. >>1 . . >>1 . . * Break out Date elements 13
Let Data Types Work For You >>1 . . PAR.$DT8 Month = PAR.$DT8 External / CON.1000000 * >>1 . . PAR.$DT8 Day = PAR.$DT8 External / CON.10000 * >>1 . . PAR.$DT8 Century = PAR.$DT8 External / CON.100 * >>1 . . PAR.$DT8 Year = PAR.$DT8 External
14
Let Data Types Work For You >>1 . . '-ENDCASE >>1 . . -*OTHERWISE >>1 . . > February in Century Non-Leap year >>1 . . .-CASE
16
Let Data Types Work For You >>1 . . '-ENDCASE >>1 . . -PAR.$DT8 Month is August >>1 . . > Test August >>1 . . .-CASE
18
19
1 > Convert DT8 1 .->>1 . > Convert DT8 >>1 . .->>1 . . * Break out Date elements >>1 . . PAR.$DT8 Century = PAR.$DT8 Internal / CON.1000000 * >>1 . . PAR.$DT8 Year = PAR.$DT8 Internal / CON.10000 * >>1 . . PAR.$DT8 Month = PAR.$DT8 Internal / CON.100 * >>1 . . PAR.$DT8 Day = PAR.$DT8 Internal >>1 . . >>1 . . * Construct External Date from Date elements >>1 . . WRK.$DT8 External = PAR.$DT8 Month >>1 . . WRK.$DT8 External = WRK.$DT8 External * CON.100 * >>1 . . WRK.$DT8 External = WRK.$DT8 External + PAR.$DT8 Day >>1 . . WRK.$DT8 External = WRK.$DT8 External * CON.100 * >>1 . . WRK.$DT8 External = WRK.$DT8 External + PAR.$DT8 Century >>1 . . WRK.$DT8 External = WRK.$DT8 External * CON.100 * >>1 . . WRK.$DT8 External = WRK.$DT8 External + PAR.$DT8 Year >>1 . . PAR.$DT8 External = WRK.$DT8 External >>1 . '-1 '-** Note that no type of validation is done when converting. The database is assumed to be correct.
20
Internal format
- US or Canadian format: left justified, separators removed - Other format: as entered
Country Code is specified as additional mapping parameter on mapping functions Context for Country Code is determined at the file level and is locked Mapping functions read Country file to get ZIP code format Mapping functions read System Control file to get default Country if input parameter is blank or invalid Special internal values identified for error reporting to prevent data loss when excess characters are entered
21
ZIP Attributes
._______________________________________________________________________________. | *CHANGE Op: SYNVG WISDM395A 2/10/92 13:09:37| | EDIT FIELD ATTRIBUTE. Test1 Model | | Field attribute. . . . : ZIP | | Text . . . . . . . . . : Zip code data Type (requires Country) | | Right hand side text . : ZIP | | Allow user Initial Allowed Override | | entry value values value | | Internal data type . . : O (I,O,H) A (A,P,S,B,F) | | Internal length. . . . : O (I,O,H) 10 | | External data type . . : A (A,S) | | External length. . . . : O (I,O,H) 12 (Output| | Keyboard shift . . . . : O (I,O,H) A XANWIDM (XANWIDM/NSYID| | Lowercase. . . . . . . : O (I,O,H) (Y,' ') | | Check valid system name: H (I,O,H) (Y,' ') | | Mandatory fill . . . . : H (I,O,H) (Y,' ') | | Modulus check 10/11. . : H (I,O,H) (10,11,' ') | | | | | | Allow value mapping. . : N (Y,N) Y (Y,' ') | | Int/ext len conv. . : (I,C,V,' ') | | Int/ext function. . : Convert Zip Int | | Ext/int function. . : Check zip Int | | | | F3=Exit F11=Delete | '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' ** Length Conversion must be blank to allow different sizes for internal and external
22
1 > Check zip Int 1 .->>1 . Check Zip - *Field attribute types * >>1 . B $Zip External.u = PAR.$Zip External.u >>1 . B $Zip Internal.u = PAR.$Zip Internal.u >>1 . B Country Cd = PAR.Country Cd 2 . > Check Zip 2 . .->>2 . . > Set all fields to blank that are altered when an error occurs >>2 . . .->>2 . . . PAR.$Zip Internal.u = CON.*BLANK >>2 . . . PGM.*Return code = CND.*Normal >>2 . . '-** Remember to completely cleanup after yourself and plan for valid and invalid exits >>2 . . > If the External has a value continue processing... >>2 . . .-CASE >>2 . . -PAR.$Zip External.u NE WRK.Blank Space.u >>2 . . $Count string characters - Utility Functions * (User Source to count String characters) >>2 . . > IF 10 or less char are present proceed... >>2 . . .-CASE >>2 . . -WRK.$String Char Total is Greater than 10 >>2 . . Send error message - 'Zip Length is invalid' >>2 . . PGM.*Return code = CND.Zip Length is invalid >>2 . . PAR.$Zip Internal.u = PGM.*Return code ** When data loss occurswhen mapping invalid values, communicate with the convert routine through the internal value >>2 . . -*OTHERWISE >>2 . . > If Country is not present, default it from the sys standard file >>2 . . .-CASE >>2 . . -PAR.Country Cd EQ WRK.Blank Space.u (RTVOBJ to get Default Country from system file) >>2 . . '-ENDCASE ** Write bulletproof code. If a needed parameter is missing an error message can get the user to enter it. But remember that the field you need may not be on the screen. Especially if the system is expected to default values. The programmer has no opportunity to default a missing value before a data type expects to use that defaulted value >>2 . . > Retrieve the country and, based on Zip format, convert it >>2 . . .-(RTVOBJ to get ZIP format from Country file) >>2 . . . > Based on the Zip format convert for internal storage. >>2 . . . .-CASE >>2 . . . -PAR.Zip Format is USA Zip+4 >>2 . . . Cvt Zip USA to Int - Country * >>2 . . . B $Zip External.u = PAR.$Zip External.u >>2 . . . B $Zip Internal.u = PAR.$Zip Internal.u ** The following imbedded function is located on the Country file. You are not limited to functions on the *Field attribute types file. This also makes the conversion routines available to other functions. 3 . . . > Cvt Zip USA to Int 3 . . . .-23
Let Data Types Work For You >>3 . . . . * All of the Action diagram is inbedded in a Sequence to allow >>3 . . . . * *Quit opcode to correctly exit to the end of the Sequence if >>3 . . . . * an error occurs.
24
Let Data Types Work For You 3 . . . .->>3 . . . . $Count string characters - Utility Functions * (User Source to count String characters) >>3 . . . . > IF Zip is Valid length process it, otherwise send an error
26
27
1 > Convert Zip Int 1 .->>1 . Convert Zip - *Field attribute types * >>1 . B $Zip External.u = PAR.$Zip External.u >>1 . B $Zip Internal.u = PAR.$Zip Internal.u >>1 . B Country Cd = PAR.Country Cd 2 . > Convert Zip 2 . .->>2 . . .-CASE >>2 . . -PAR.$Zip Internal.u is Zip is in error >>2 . . * Do nothing to the Zip the external needs to stay intact. ** Recall that errors were communicated to this routine by special values in the internal field. Simply exiting leaves the external value (which may be too long) intact. Compare this with Synon's handling of value-mapped STS fields. >>2 . . -PAR.$Zip Internal.u EQ WRK.Blank Space.u >>2 . . PAR.$Zip External.u = CON.*BLANK ** Remember to code for optional fields >>2 . . -*OTHERWISE >>2 . . > If Country Code is not supplied default it from the sys control fil >>2 . . .-CASE >>2 . . -PAR.Country Cd EQ WRK.Blank Space.u (RTVOBJ to get Default Country from system file) >>2 . . '-ENDCASE >>2 . . > Rtv country for zip format and build zip for display >>2 . . .-(RTVOBJ to get ZIP format from Country file) >>2 . . . > Based on zip format, convert the internal format to external >>2 . . . .-CASE >>2 . . . -PAR.Zip Format is USA Zip+4 >>2 . . . Convert Zip to USA Zip+4 - Country * >>2 . . . I $Zip Internal.u = PAR.$Zip Internal.u >>2 . . . B $Zip External.u = PAR.$Zip External.u 3 . . . > Convert Zip to USA Zip+4 3 . . . .->>3 . . . . $Count string characters - Utility Functions * (User Source to count String characters) >>3 . . . . .-CASE >>3 . . . . -WRK.String Count.u is Five >>3 . . . . PAR.$Zip External.u = PAR.$Zip Internal.u >>3 . . . . -*OTHERWISE >>3 . . . . > Break the Zip Code Down into Base components >>3 . . . . .->>3 . . . . . $Subst (Substring) - Utility Functions * (User Source to substring retrieves characters 1 - 5) >>3 . . . . . $Subst (Substring) - Utility Functions * (User Source to substring retrieves characters 6 - 9) >>3 . . . . '->>3 . . . . > Reassemble the Zip with the edit character(s) in place. >>3 . . . . .->>3 . . . . . $Concat without sep - Utility Functions * (User Source to concatenate combines first piece of ZIP and '-') 28
Let Data Types Work For You >>3 . . . . . $Concat without sep - Utility Functions * (User Source to concatenate combines previous string with second piece of ZIP) >>3 . . . . '->>3 . . . . '-ENDCASE
29
30
CC# Attributes
._______________________________________________________________________________. | *ADD Op: SYNDSNR WISRMT2S1 1/26/92 8:52:50| | EDIT FIELD ATTRIBUTE. Windsor, Inc. WISDMMDL | | Field attribute. . . . : CC# | | Text . . . . . . . . . : Credit Card Number | | Right hand side text . : | | Allow user Initial Allowed Override | | entry value values value | | Internal data type . . : O (I,O,H) A (A,P,S,B,F) | | Internal length. . . . : O (I,O,H) 16 | | External data type . . : A (A,S) | | External length. . . . : O (I,O,H) 19 (Output| | Keyboard shift . . . . : O (I,O,H) M XANWIDM (XANWIDM/NSYID| | Lowercase. . . . . . . : H (I,O,H) (Y,' ') | | Check valid system name: H (I,O,H) (Y,' ') | | Mandatory fill . . . . : O (I,O,H) (Y,' ') | | Modulus check 10/11. . : H (I,O,H) (10,11,' ') | | | | | | Allow value mapping. . : N (Y,N) Y (Y,' ') | | Int/ext len conv. . : (I,C,V,' ') | | Int/ext function. . : Convert Credit Card # | | Ext/int function. . : Check Credit Card # | | | | F3=Exit | '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' ** Note internal and external sizes. Again, value mapping is required to allow use of mapping functions. ** Keyboard shift M allows least number of non-numeric keys while still allowing blanks to be keyed. 31
Ignored Character CC# Digit Check Control Cond: Between 1 and 19 CC# Char Count
N N
NBR NBR
VAL RNG
2.0 2.0
1 > Check CC# 1 .->>1 . * Check CC# data type for invalid length and invalid characters. >>1 . After validating, convert to internal format. >>1 . >>1 . * Prepare to count and process individual characters >>1 . PAR.CC# Char Count = CON.*ZERO >>1 . PAR.CC# Digit Check Control = CON.1 >>1 . PAR.CC# Internal Value = CON.*BLANK >>1 . >>1 . > Process characters in string >>1 . .=REPEAT WHILE >>1 . |-PAR.CC# Digit Check Control is Between 1 and 19 >>1 . | $Substring - (Utility Functions) * >>1 . | I VRY $String Length.u = CON.1 >>1 . | I VRY $String.u = PAR.CC# External Value >>1 . | I VRY $String start pos.u = PAR.CC# Digit Check Control >>1 . | O VRY $String result.u = PAR.CC# Digit/Char >>1 . | >>1 . | > Issue error message if invalid character encountered >>1 . | .-CASE >>1 . | -PAR.CC# Digit/Char is Invalid Character >>1 . | Send error message - '$Invalid CC# character' >>1 . | I CC# External Value = PAR.CC# External Value >>1 . | I CC# Digit/Char = PAR.CC# Digit/Char >>1 . | PAR.CC# Internal Value = CND.Invalid Number on Edit ** Again note the use of the internal value to communicate errors. This time conditionson the parameter field are used. >>1 . | '-ENDCASE >>1 . | >>1 . | > If character is not an ignored character (blank), count it. >>1 . | .-CASE >>1 . | -PAR.CC# Digit/Char is Ignored Character >>1 . | -*OTHERWISE >>1 . | PAR.CC# Char Count = PAR.CC# Char Count + CON.1 >>1 . | '-ENDCASE >>1 . | >>1 . | * Increment loop counter >>1 . | PAR.CC# Digit Check Control = PAR.CC# Digit Check Control + CON.1 >>1 . '-ENDWHILE >>1 . 32
Let Data Types Work For You >>1 . > Issue error if number is too long >>1 . .-CASE >>1 . -PAR.CC# Char Count is Greater than 16
33
34
1 > Convert CC# 1 .->>1 . * Convert Internal to External for CC# Data Type >>1 . >>1 . > If edit error, return ext value else convert int to ext. >>1 . .-CASE >>1 . -PAR.CC# Internal Value is Invalid Number on Edit >>1 . >>1 . * Do nothing: This allows external value to remain intact on error >>1 . ** Remember to test for error condition communicated from the Check function >>1 . -*OTHERWISE >>1 . * Perform 4 substring and concatenates to break 16 digit internal >>1 . value into 4 segments with 1 space separator. >>1 . PAR.CC# External Value = CON.*BLANK >>1 . $Substring - (Utility Functions) * >>1 . I VRY $String Length.u = CON.4 >>1 . I VRY $String.u = PAR.CC# Internal Value >>1 . I VRY $String start pos.u = CON.1 >>1 . O VRY $String result.u = PAR.CC# Segment >>1 . $Concat without sep - (Utility Functions) * >>1 . I VRY $Concat String 1 = PAR.CC# External Value >>1 . I VRY $Concat String 2 = PAR.CC# Segment >>1 . O VRY $Concat Result = PAR.CC# External Value >>1 . $Substring - (Utility Functions) * >>1 . (Other Parms same as above) >>1 . I VRY $String start pos.u = CON.5 >>1 . $Concat with blank sep - (Utility Functions) * >>1 . (Parms same as above) >>1 . $Substring - (Utility Functions) * >>1 . (Other Parms same as above) >>1 . I VRY $String start pos.u = CON.9 >>1 . $Concat with blank sep - (Utility Functions) * >>1 . (Parms same as above) >>1 . $Substring - (Utility Functions) * >>1 . (Other Parms same as above) >>1 . I VRY $String start pos.u = CON.13 >>1 . $Concat with blank sep - (Utility Functions) * >>1 . (Parms same as above) >>1 . '-ENDCASE 1 '--
35
RPT Attributes
._______________________________________________________________________________. | *CHANGE Op: SYNVG WISRMT2S1 2/15/92 17:37:56| | EDIT FIELD ATTRIBUTE. Test1 Model | | Field attribute. . . . : RPT | | Text . . . . . . . . . : External: Rate per 1000 Internal: Rate per Unit | | Right hand side text . : per 1000 | | Allow user Initial Allowed Override | | entry value values value | | Internal data type . . : O (I,O,H) P (A,P,S,B,F) | | Internal length. . . . : I (I,O,H) 6.3 | | External data type . . : S (A,S) | | External length. . . . : O (I,O,H) 6.0 (Output| | Keyboard shift . . . . : I (I,O,H) NSYID (XANWIDM/NSYID| | Lowercase. . . . . . . : H (I,O,H) (Y,' ') | | Check valid system name: H (I,O,H) (Y,' ') | | Mandatory fill . . . . : I (I,O,H) (Y,' ') | | Modulus check 10/11. . : H (I,O,H) (10,11,' ') | | | | | | Allow value mapping. . : N (Y,N) Y (Y,' ') | | Int/ext len conv. . : C (I,C,V,' ') | | Int/ext function. . : Convert RPT | | Ext/int function. . : Check RPT | | | | F3=Exit F11=Delete | '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' ** Length Conversion requires C to use length conversion program 36
1 1 >>1 >>1 >>1 >>1 >>1 >>1 >>1 >>1 >>1 >>1 >>1 >>1
integers = CON.3 - PAR.Internal no. of decimals integers = PAR.Internal no. of integers + WRK.Exter (nal no. of integers) >>1 . WRK.External no. of decimals = CON.*ZERO ** This causes the Integer portion to be increased by the number of digits needed to offset the movement of the decimal point. >>1 . '-ENDCASE >>1 . >>1 . PAR.External length = WRK.External no. of integers >>1 . PAR.External no. of integers = WRK.External no. of integers >>1 . PAR.External no. of decimals = WRK.External no. of decimals 1 '--
> Calc RPT length .-. Size . ** Examples: 5.0 . 5.2 . 5.4 . 5.5 . .-CASE . -PAR.Internal no. of . WRK.External no. of . WRK.External no. of . -*OTHERWISE . WRK.External no. of . WRK.External no. of
decimals is greater than 3 decimals = PAR.Internal no. of decimals - CON.3 integers = PAR.Internal no. of integers
37
38
Other Ideas
Use in place of Derived fields for name formatting, etc
- Allows multiple fields of different sizes to be constructed all using the same action diagram - Allows parameters values supplied to function to be changed at the device level rather than visiting action diagram - Internal/External conversion routine only
39
40