home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR36 / C7101.ZIP / SCRNFLDS.TPX < prev    next >
Text File  |  1994-01-26  |  43KB  |  582 lines

  1. #!┌───────────────────────────┤Template Segment├───────────┬─────────────────┐
  2. #!│                              SrcnFlds.TPX              │Version: 3007.100│
  3. #!├───────────────────────────────┤Contents├───────────────┴─────────────────┤
  4. #!│Structure             Type       Description                              │
  5. #!│────────────────────  ─────────  ─────────────────────────────────────────│
  6. #!│ScreenSetupRoutines   GROUP      Pre-Edit (When field is selected) code   │
  7. #!│ScreenEditRoutines    GROUP      Post-Edit (When field is completed) code │
  8. #!│FieldEditCode         GROUP      Writes code associated with "When field  │
  9. #!│                                   Is Completed" fields                   │
  10. #!│PrimeRelationFields   GROUP      Primes relation key fields and return    │
  11. #!│                                   values before procedure call           │
  12. #!│FillRelationFields    GROUP      Refills relation key fields and return   │
  13. #!│                                   values after procedure call            │
  14. #!│ScreenEditLookupCode  GROUP      Generates code associated with Must-Be-  │
  15. #!│                                   In-File validations                    │
  16. #!│CallScreenFieldEdit   GROUP      Generates code associated with non-Must- │
  17. #!│                                   Be-In-File post-edit code              │
  18. #!│PrimeLookups          GROUP      Searches the dictionary for lookups or   │
  19. #!│                                   relations for a screen field           │
  20. #!│RangeCode             GROUP      Generates Range Validation Code          │
  21. #!│FieldLookupCode       GROUP      Generates Post-Edit Must-Be-In-File      │
  22. #!│                                   field validation                       │
  23. #!│SetGenerationFlags    GROUP      Sets flags to generate CASE SELECTED()   │
  24. #!│                                   and CASE FIELD() structures in main    │
  25. #!│                                   body accept loops                      │
  26. #!├───────────────────────────────┤Comments├─────────────────────────────────┤
  27. #!│Version   Comments                                                        │
  28. #!│────────  ────────────────────────────────────────────────────────────────│
  29. #!│3007.000  Release of CDD3 version 3007 templates                          │
  30. #!│3007.100  %ScreenSetupRoutines repaired                                   │
  31. #!└──────────────────────────────────────────────────────────────────────────┘
  32. #!
  33. #GROUP(%ScreenSetupRoutines)                     #!Write Screen Field Setup Code
  34. #!
  35. #!┌────────────────────────────┤Template Group├────────────┬─────────────────┐
  36. #!│                          %ScreenSetupRoutines          │Version: 3007.100│
  37. #!├──────────────────────────────┤Description├─────────────┴─────────────────┤
  38. #!│Purpose:      Generate Pre-Edit (When Field is Selected) code for ENTRY   │
  39. #!│              fields.                                                     │
  40. #!│Called From:  Any procedure template that has a screen defined            │
  41. #!│Assumptions:  That a %Screen is defined.                                  │
  42. #!│Inserts:      %PrimeLookups                                               │
  43. #!│              %PrimeRelationFields                                        │
  44. #!│              %FillRelationFields                                         │
  45. #!│Symbols Set:  None                                                        │
  46. #!│Notes:        This group generates all of the "OF xxx" cases for the      │
  47. #!│              CASE SELECTED() structure of an accept loop.                │
  48. #!├───────────────────────────────┤Comments├─────────────────────────────────┤
  49. #!│Version   Comments                                                        │
  50. #!│────────  ────────────────────────────────────────────────────────────────│
  51. #!│3007.000  Release of CDD3 version 3007 templates                          │
  52. #!│3007.100  Repaired faulty assignment statement.  Line read:               │
  53. #!│          %ScreenFieldUse <> %ScreenFieldSetupReturnValue, should be:     │
  54. #!│          %ScreenFieldUse = %ScreenFieldSetupReturnValue.                 │
  55. #!└──────────────────────────────────────────────────────────────────────────┘
  56. #!
  57. #FOR(%ScreenField)                               #! FOR Each Screen Field
  58.   #IF(%ScreenFieldSetup)                         #! IF Setup Code Provided
  59. OF %ScreenField                                  #<! Setup %ScreenFieldUse field
  60.     #IF(%ScreenFieldSetupType='PROCEDURE')       #! If Setup is Proc Call
  61.       #SET(%LookupFromField,%Null)               #! Clear lookup field flag
  62.       #SET(%LookupFromFile,%Null)                #! Clear lookup file flag
  63.       #FIX(%Field,%ScreenFieldUse)               #! FIX to process FIELD
  64.       #FIX(%File,%FieldFile)                     #! FIX to process FIELD FILE
  65.       #IF(%NonStopSelect)                        #! IF proc has 'Save Mode'
  66.   IF ~NonStopSelect                              #<! IF Not in Save Mode
  67.       #ENDIF                                     #! END (If proc has save mode)
  68.       #SET(%LocateField,%ScreenFieldSetupReturnValue) #! Find Return Value, is any
  69.       #INSERT(%PrimeLookups)                     #! Look For Relations
  70.       #IF(%LookupFromFile)                       #! IF a Related File Found
  71.         #FIX(%Relation,%LookupFromFile)          #! FIX to process RELATION
  72.     #INSERT(%PrimeRelationFields)                #! Prime Key Fields
  73.       #ELSE                                      #! ELSE (No Related File)
  74.         #IF(%ScreenFieldSetupReturnValue)        #! If Return Value provided
  75.     %ScreenFieldSetupReturnValue = %ScreenFieldUse #<! Prime Return Value
  76.         #ENDIF                                   #! END (If Return Value...)
  77.       #ENDIF                                     #! END (If No Relation)
  78.     SETKEYCODE(ShftEnter)                        #<! Set KeyCode for Selection
  79.     %ScreenFieldSetup                            #<! Call the Setup Proc
  80.       #IF(%LookupFromFile)                       #! IF a Related File Found
  81.     #INSERT(%FillRelationFields)                 #! Fill the key fields
  82.       #ELSE                                      #! ELSE (No Related File)
  83.         #IF(%ScreenFieldSetupReturnValue)        #! If Return Value provided
  84.     IF KEYCODE() <> EscKey                       #<! IF User didn't ESCAPE
  85.       %ScreenFieldUse = %ScreenFieldSetupReturnValue #<! Fill Screen Field
  86.     END                                          #<! END (IF User didn't Escape)
  87.         #ENDIF                                   #! END (IF Return Value)
  88.       #ENDIF                                     #! END (If Related File...)
  89.     DISPLAY                                      #<! DISPLAY new values
  90.       #IF(%NonStopSelect)                        #! IF proc has 'Save Mode'
  91.   END                                            #<! END (If Not in 'Save Mode')
  92.       #ENDIF                                     #! END (IF Proc has save mode)
  93.     #ELSE                                        #! ELSE (Setup not Proc Call)
  94.   %ScreenFieldSetup                              #<! Write Setup Code
  95.     #ENDIF                                       #! END (If Setup Proc Call)
  96.   #ENDIF                                         #! END (If Setup Provided)
  97. #ENDFOR                                          #! END (For Each Screen Field)
  98. #!***************************************************************************
  99. #GROUP(%ScreenEditRoutines)                      #!Write Screen Field Edit Code
  100. #!
  101. #!┌────────────────────────────┤Template Group├────────────┬─────────────────┐
  102. #!│                          %ScreenEditRoutines           │Version: 3007.000│
  103. #!├──────────────────────────────┤Description├─────────────┴─────────────────┤
  104. #!│Purpose:      Generate Post-Edit (When Field is Completed) code for ENTRY │
  105. #!│              fields.                                                     │
  106. #!│Called From:  Any procedure template that has a screen defined            │
  107. #!│Assumptions:  That a %Screen is defined, and that %ScreenField is fixed   │
  108. #!│              to a valid screen field.                                    │
  109. #!│Inserts:      %RangeCode                                                  │
  110. #!│              %FieldEditCode                                              │
  111. #!│              %FieldLookupCode                                            │
  112. #!│Symbols Set:  None                                                        │
  113. #!│Notes:        This group generates one "OF xxx" case for the CASE FIELD() │
  114. #!│              structure of an accept loop.                                │
  115. #!├───────────────────────────────┤Comments├─────────────────────────────────┤
  116. #!│Version   Comments                                                        │
  117. #!│────────  ────────────────────────────────────────────────────────────────│
  118. #!│3007.000  Release of CDD3 version 3007 templates                          │
  119. #!└──────────────────────────────────────────────────────────────────────────┘
  120. #!
  121. #IF(%ScreenFieldType='ENTRY')                    #! IF an ENTRY field
  122.   #FIX(%Field,%ScreenFieldUse)                   #! FIX to process FIELD
  123.   #FIX(%File,%FieldFile)                         #! FIX to process FIELD FILE
  124.   #SET(%GenScreenFieldEdit,'TRUE')               #! Default to Gen Edit Code
  125.   #SET(%GenRangeCode,%Null)                      #! Default to NOT gen range code
  126.   #IF(%FieldRangeLow)                            #! IF a Low range on field
  127.     #SET(%GenRangeCode,'TRUE')                   #! Flag to gen range code
  128.   #ELSIF(%FieldRangeHigh)                        #! IF a High range on field
  129.     #SET(%GenRangeCode,'TRUE')                   #! Flag to gen range code
  130.   #ELSIF(%FieldLookup)                           #! if Must Be In File
  131.   #ELSIF(%ScreenFieldEdit)                       #! or Edit Code provided
  132.   #ELSE                                          #! otherwise
  133.     #SET(%GenScreenFieldEdit,%Null)              #! Flag to NOT gen code
  134.   #ENDIF                                         #! END (If FieldRangeLow...)
  135.   #IF(%GenScreenFieldEdit)                       #! IF we have to gen edit code
  136.     #SET(%LookupFromField,%Null)                 #! Clear lookup field flag
  137.     #SET(%LookupFromFile,%Null)                  #! Clear lookup file flag
  138. OF %ScreenField                                  #<! Completed %ScreenFieldUse field
  139.     #IF(%GenRangeCode)                           #! IF Range Code Needed
  140.   #INSERT(%RangeCode)                            #! Generate Range Code
  141.     #ENDIF                                       #! END (If range code needed)
  142.     #IF(%ScreenFieldEdit)                        #! IF Edit Code Provided
  143.   #INSERT(%FieldEditCode)                        #! Generate Edit Code
  144.     #ENDIF                                       #! END (If Edit Code...)
  145.     #IF(%FieldLookup)                            #! IF Must Be In File
  146.   #INSERT(%FieldLookupCode)                      #! Generate Validation Code
  147.     #ENDIF                                       #! END (If Must Be...)
  148.   #ENDIF                                         #! END (If gen Edit Code)
  149. #ELSE                                            #! ELSE (If not entry field)
  150.   #IF(%ScreenFieldEdit)                          #! If Edit Code Provided
  151. OF %ScreenField                                  #<! Completed %ScreenFieldUse field
  152.   %ScreenFieldEdit                               #<! Generate Edit Code
  153.   DISPLAY                                        #<! DISPLAY new value
  154.   #ENDIF                                         #! END (If Edit Code...)
  155. #ENDIF                                           #! END (If Entry Field)
  156. #!***************************************************************************
  157. #GROUP(%FieldEditCode)                           #!Proc/Source Code Generation
  158. #!
  159. #!┌────────────────────────────┤Template Group├────────────┬─────────────────┐
  160. #!│                             %FieldEditCode             │Version: 3007.000│
  161. #!├──────────────────────────────┤Description├─────────────┴─────────────────┤
  162. #!│Purpose:      Writes code associated with "When Field Is Completed"       │
  163. #!│              Procedure Calls                                             │
  164. #!│Called From:  %ScreenEditRoutines #GROUP                                  │
  165. #!│Assumptions:  That a %Screen is defined, and that %ScreenField is fixed   │
  166. #!│              to a valid screen field.                                    │
  167. #!│Inserts:      %PrimeLookups                                               │
  168. #!│              %ScreenEditLookupCode                                       │
  169. #!│              %CallScreenFieldEdit                                        │
  170. #!│Symbols Set:  None                                                        │
  171. #!│Notes:        None                                                        │
  172. #!├───────────────────────────────┤Comments├─────────────────────────────────┤
  173. #!│Version   Comments                                                        │
  174. #!│────────  ────────────────────────────────────────────────────────────────│
  175. #!│3007.000  Release of CDD3 version 3007 templates                          │
  176. #!└──────────────────────────────────────────────────────────────────────────┘
  177. #!
  178. #IF(ScreenFieldEditType='PROCEDURE')             #! IF Edit Code is Proc Name
  179.   #SET(%LocateField,%ScreenFieldEditReturnValue) #! Prime Locate Field
  180.   #INSERT(%PrimeLookups)                         #! Look For Relations
  181.   #IF(%LookupFromFile)                           #! IF a Related File Found
  182.                                                  #<! Field Related to %LookupFromField
  183.     #FIX(%Relation,%LookupFromFile)              #! FIX to process RELATION
  184. #INSERT(%ScreenEditLookupCode)                   #! and Call the Lookup Code
  185.   #ELSE                                          #! ELSE (If no Relation)
  186.                                                  #<! No Relation Found
  187.     #IF(%ScreenFieldEditHotKey)                  #! If a Hot Key specified
  188.                                                  #<! %ScreenFieldEditHotKey calls PROC
  189. IF KEYCODE() = %ScreenFieldEditHotKey            #<! IF Hotkey completed field
  190.   #INSERT(%CallScreenFieldEdit)                  #! write non-lookup edit code
  191.   DISPLAY                                        #<! Display New Values
  192. END                                              #<! END (IF hotkey...)
  193.     #ELSE                                        #! ELSE (No Hotkey provided)
  194.       #IF(%NonStopSelect)                        #! IF In Proc with field validation
  195. IF ~NonStopSelect                                #<! IF NOT in non-stop select
  196.   #INSERT(%CallScreenFieldEdit)                  #! write non-lookup edit code
  197.   DISPLAY                                        #<! Display New Values
  198. END                                              #<! END (If NOT Non-Stop...)
  199.       #ELSE                                      #! ELSE (Not in Non-Stop Proc)
  200. #INSERT(%CallScreenFieldEdit)                    #! write non-lookup edit code
  201. DISPLAY                                          #<! Display New Values
  202.       #ENDIF                                     #! END (If Non-Stop Select)
  203.     #ENDIF                                       #! END (If Hot Key Defined)
  204.   #ENDIF                                         #! END (If Related File Found)
  205. #ELSE                                            #! ELSE (Not a Proc Call)
  206. %ScreenFieldEdit                                 #<! Write Source Code
  207. #ENDIF                                           #! END (If Edit Code...)
  208. #!***************************************************************************
  209. #GROUP(%PrimeRelationFields)                     #!Prime all Related Fields
  210. #!
  211. #!┌────────────────────────────┤Template Group├────────────┬─────────────────┐
  212. #!│                          %PrimeRelationFields          │Version: 3007.000│
  213. #!├──────────────────────────────┤Description├─────────────┴─────────────────┤
  214. #!│Purpose:      Fills relation and return value fields before Pre and Post  │
  215. #!│              Edit Procedure Calls.                                       │
  216. #!│Called From:  %ScreenEditLookupCode                                       │
  217. #!│              %ScreenSetupRoutines                                        │
  218. #!│Assumptions:  That a %Relation exists between the screen field file and   │
  219. #!│              the return value, or Must-Be-in-File is set for the screen  │
  220. #!│              entry field.  In either case, %Relation is assumed to be    │
  221. #!│              #FIXed.                                                     │
  222. #!│              That %LocateField is set to EITHER Edit or Setup Return     │
  223. #!│              value                                                       │
  224. #!│Inserts:      None                                                        │
  225. #!│Symbols Set:  None                                                        │
  226. #!│Notes:        None                                                        │
  227. #!├───────────────────────────────┤Comments├─────────────────────────────────┤
  228. #!│Version   Comments                                                        │
  229. #!│────────  ────────────────────────────────────────────────────────────────│
  230. #!│3007.000  Release of CDD3 version 3007 templates                          │
  231. #!└──────────────────────────────────────────────────────────────────────────┘
  232. #!
  233. #SET(%AssignReturnValue,%LocateField)            #! Default Return Value Assign
  234. #FOR(%RelationKeyField)                          #! FOR fields in Relation Key
  235. %RelationKeyField = %RelationKeyFieldLink        #<! Prime Related Field
  236.   #IF(UPPER(%RelationKeyFieldLink) = UPPER(%ScreenFieldUse)) #! IF Link was written
  237.     #IF(UPPER(%RelationKeyField) = UPPER(%LocateField)) #! IF Linked to Return Value
  238.       #SET(%AssignReturnValue,%Null)             #! Clear Return Value Flag
  239.     #ENDIF                                       #! END (IF Linked to...)
  240.     #BREAK                                       #! Quit Processing
  241.   #ENDIF                                         #! END (If Link written)
  242. #ENDFOR                                          #! END (For RelationKeyField)
  243. #IF(%AssignReturnValue)                          #! IF Assignment needed
  244. %LocateField = %ScreenFieldUse                   #<! Fill the Return Value
  245. #ENDIF                                           #! END (If Assignment Needed)
  246. #!***************************************************************************
  247. #GROUP(%FillRelationFields)                      #!Fill all relation Fields
  248. #!
  249. #!┌────────────────────────────┤Template Group├────────────┬─────────────────┐
  250. #!│                          %PrimeRelationFields          │Version: 3007.000│
  251. #!├──────────────────────────────┤Description├─────────────┴─────────────────┤
  252. #!│Purpose:      Fills relation and screen field after Pre and Post Edit     │
  253. #!│              Procedure Calls.                                            │
  254. #!│Called From:  %ScreenEditLookupCode                                       │
  255. #!│              %ScreenSetupRoutines                                        │
  256. #!│Assumptions:  That a %Relation exists between the screen field file and   │
  257. #!│              the return value, or Must-Be-in-File is set for the screen  │
  258. #!│              entry field.  In either case, %Relation is assumed to be    │
  259. #!│              #FIXed.                                                     │
  260. #!│              That %LocateField is set to EITHER Edit or Setup Return     │
  261. #!│              value                                                       │
  262. #!│Inserts:      None                                                        │
  263. #!│Symbols Set:  None                                                        │
  264. #!│Notes:        None                                                        │
  265. #!├───────────────────────────────┤Comments├─────────────────────────────────┤
  266. #!│Version   Comments                                                        │
  267. #!│────────  ────────────────────────────────────────────────────────────────│
  268. #!│3007.000  Release of CDD3 version 3007 templates                          │
  269. #!└──────────────────────────────────────────────────────────────────────────┘
  270. #!
  271. IF KEYCODE()<>EscKey                             #<! IF User didn't ESCAPE
  272. #SET(%AssignReturnValue,%LocateField)            #! Default Return Value Assign
  273. #FOR(%RelationKeyField)                          #! FOR fields in Relation Key
  274.   %RelationKeyFieldLink = %RelationKeyField      #<! Fill Related Field
  275.   #IF(UPPER(%RelationKeyFieldLink) = UPPER(%ScreenFieldUse)) #! IF Link was written
  276.     #IF(UPPER(%RelationKeyField) = UPPER(%LocateField)) #! IF Linked to Return Value
  277.       #SET(%AssignReturnValue,%Null)             #! Clear Return Value Flag
  278.     #ENDIF                                       #! END (IF Linked to...)
  279.     #BREAK                                       #! Quit Processing
  280.   #ENDIF                                         #! END (If Link written)
  281. #ENDFOR                                          #! END (For RelationKeyField)
  282. #IF(%AssignReturnValue)                          #! IF Assignment needed
  283.   %ScreenFieldUse = %LocateField                 #<! Fill from Return Value
  284. #ENDIF                                           #! END (If Assignment Needed)
  285. END                                              #<! END (If User didn't ESCAPE)
  286. #!***************************************************************************
  287. #GROUP(%ScreenEditLookupCode)                    #!Generate Code for Lookups
  288. #!
  289. #!┌────────────────────────────┤Template Group├────────────┬─────────────────┐
  290. #!│                         %ScreenEditLookupCode          │Version: 3007.000│
  291. #!├──────────────────────────────┤Description├─────────────┴─────────────────┤
  292. #!│Purpose:      Generates code associated with Must-Be-In-File post-edit    │
  293. #!│              code                                                        │
  294. #!│Called From:  %FieldEditCode                                              │
  295. #!│Assumptions:  None                                                        │
  296. #!│Inserts:      None                                                        │
  297. #!│Symbols Set:  None                                                        │
  298. #!│Notes:        None                                                        │
  299. #!├───────────────────────────────┤Comments├─────────────────────────────────┤
  300. #!│Version   Comments                                                        │
  301. #!│────────  ────────────────────────────────────────────────────────────────│
  302. #!│3007.000  Release of CDD3 version 3007 templates                          │
  303. #!└──────────────────────────────────────────────────────────────────────────┘
  304. #!
  305. #IF(%FieldLookup)                                #! IF Must Be In File
  306.                                                  #<! Must be in %FieldLookup
  307. #INSERT(%PrimeRelationFields)                    #! Prime Key Fields
  308. GET(%Relation,%RelationKey)                      #<! Look for parent record
  309.   #IF(%ScreenFieldEditHotKey)                    #! IF a Hot Key is Defined
  310.                                                  #<! %ScreenFieldEditHotKey calls PROC
  311.     #IF(%ScreenFieldRequired)                    #! IF Screen Field is required
  312. IF ERRORCODE() OR KEYCODE() = %ScreenFieldEditHotKey#<! If Not Found or Hotkey
  313.     #ELSE                                        #! ELSE (IF NOT Screen Field...)
  314. IF (%ScreenFieldUse AND ERRORCODE()) OR KEYCODE() = %ScreenFieldEditHotKey#<! If Not Found or Hotkey
  315.     #ENDIF                                       #! END (IF Screen Field...)
  316.   SETKEYCODE(ShftEnter)                          #<! Set Keycode for Select
  317.   %ScreenFieldEdit                               #<! Call the Select Proc
  318.   #INSERT(%FillRelationFields)                   #! Fill the key fields
  319.   SELECT(%ScreenField)                           #<! and re-select the field
  320. END                                              #<! END (If No Parent or Hotkey)
  321.   #ELSE                                          #! ELSE (No Hotkey)
  322. IF ERRORCODE()                                   #<! If Not Found
  323.   SETKEYCODE(ShftEnter)                          #<! Set Keycode for Select
  324.   %ScreenFieldEdit                               #<! Call the Select Proc
  325.   #INSERT(%FillRelationFields)                   #! Fill the key fields
  326.   SELECT(%ScreenField)                           #<! and re-select the field
  327. END                                              #<! END (If Not Found)
  328.   #ENDIF                                         #! END (If HotKey)
  329. #ELSE                                            #! ELSE (Not Must Be In File)
  330.                                                  #<! Must Be In File NOT SET
  331.   #IF(%ScreenFieldEditHotKey)                    #! IF a Hot Key is Defined
  332.                                                  #<! %ScreenFieldEditHotKey calls PROC
  333. IF KEYCODE() = %ScreenFieldEditHotKey            #<! IF HotKey completed field
  334.   #INSERT(%PrimeRelationFields)                  #! Prime Key Fields
  335.   SETKEYCODE(ShftEnter)                          #<! Set Keycode for Select
  336.   %ScreenFieldEdit                               #<! Call the Select Proc
  337.   #INSERT(%FillRelationFields)                   #! Fill the key fields
  338.   SELECT(%ScreenField)                           #<! and re-select the field
  339. END                                              #<! END (If HotKey Pressed)
  340.   #ELSE                                          #! ELSE (No HotKey)
  341.     #IF(%NonStopSelect)                          #! IF In Proc with field validation
  342. IF ~NonStopSelect                                #<! IF NOT in non-stop select
  343.   #INSERT(%PrimeRelationFields)                  #! Prime Key Fields
  344.   SETKEYCODE(ShftEnter)                          #<! Set Keycode for Select
  345.   %ScreenFieldEdit                               #<! Call the Select Proc
  346.   #INSERT(%FillRelationFields)                   #! Fill the key fields
  347. END                                              #<! END (If NOT Non-Stop...)
  348.     #ELSE                                        #! ELSE (Not in Non-Stop Proc)
  349. #INSERT(%PrimeRelationFields)                    #! Prime Key Fields
  350. SETKEYCODE(ShftEnter)                            #<! Set Keycode for Select
  351. %ScreenFieldEdit                                 #<! Call the Select Proc
  352. #INSERT(%FillRelationFields)                     #! Fill the key fields
  353.     #ENDIF                                       #! END (If Non-Stop Select)
  354.   #ENDIF                                         #! END (If Hot Key Defined)
  355. #ENDIF                                           #! END (If Field Lookup)
  356. #!***************************************************************************
  357. #GROUP(%CallScreenFieldEdit)                     #!Call code for non-lookups
  358. #!
  359. #!┌────────────────────────────┤Template Group├────────────┬─────────────────┐
  360. #!│                          %CallScreenFieldEdit          │Version: 3007.000│
  361. #!├──────────────────────────────┤Description├─────────────┴─────────────────┤
  362. #!│Purpose:      Generates code associated with non-Must-Be-In-File          │
  363. #!│              post-edit code                                              │
  364. #!│Called From:  %FieldEditCode                                              │
  365. #!│Assumptions:  None                                                        │
  366. #!│Inserts:      None                                                        │
  367. #!│Symbols Set:  None                                                        │
  368. #!│Notes:        None                                                        │
  369. #!├───────────────────────────────┤Comments├─────────────────────────────────┤
  370. #!│Version   Comments                                                        │
  371. #!│────────  ────────────────────────────────────────────────────────────────│
  372. #!│3007.000  Release of CDD3 version 3007 templates                          │
  373. #!└──────────────────────────────────────────────────────────────────────────┘
  374. #!
  375. #IF(%ScreenFieldEditReturnValue)                 #! IF a Return Value provided
  376. %ScreenFieldEditReturnValue = %ScreenFieldUse    #<! Prime Return Value
  377. #ENDIF                                           #! END (If a Return Value...)
  378. SETKEYCODE(ShftEnter)                            #<! Set KeyCode for Selection
  379. %ScreenFieldEdit                                 #<! Call the Edit Proc
  380. #IF(%ScreenFieldEditReturnValue)                 #! IF a Return Value provided
  381. IF KEYCODE() <> EscKey                           #<! IF User didn't ESCAPE
  382.   %ScreenFieldUse = %ScreenFieldEditReturnValue  #<! Fill the Return Value
  383. END                                              #<! END (If User didn't...)
  384. #ENDIF                                           #! END (If a Return Value...)
  385. #!***************************************************************************
  386. #GROUP(%PrimeLookups)                            #!Prime Lookup Values
  387. #!
  388. #!┌────────────────────────────┤Template Group├────────────┬─────────────────┐
  389. #!│                              %PrimeLookups             │Version: 3007.000│
  390. #!├──────────────────────────────┤Description├─────────────┴─────────────────┤
  391. #!│Purpose:      Searches the dictionary for lookups or relations for a      │
  392. #!│              screen field                                                │
  393. #!│Called From:  %ScreenSetupRoutines                                        │
  394. #!│              %FieldEditCode                                              │
  395. #!│Assumptions:  None                                                        │
  396. #!│Inserts:      None                                                        │
  397. #!│Symbols Set:  None                                                        │
  398. #!│Notes:        None                                                        │
  399. #!├───────────────────────────────┤Comments├─────────────────────────────────┤
  400. #!│Version   Comments                                                        │
  401. #!│────────  ────────────────────────────────────────────────────────────────│
  402. #!│3007.000  Release of CDD3 version 3007 templates                          │
  403. #!└──────────────────────────────────────────────────────────────────────────┘
  404. #!
  405. #IF(%FieldLookup)                                #! IF Must Be In File
  406.   #FIX(%Relation,%FieldLookup)                   #! FIX the Relation to %File
  407.   #IF(%Relation)                                 #! IF the FIX was successful
  408.     #IF(%RelationType='MANY:1')                  #! IF the Relation is Many:1
  409.       #FOR(%RelationKeyField)                    #! Cycle through Key Fields
  410.         #IF(%RelationKeyFieldLink)               #! If a Linked Field Exists
  411.           #IF(UPPER(%RelationKeyFieldLink)=UPPER(%ScreenFieldUse)) #!If Linked Field=Screen Field
  412.             #SET(%LookupFromFile,%Relation)      #! Flag RelatedFile
  413.             #SET(%LookupFromField,%RelationKeyField) #!Flag Related Field
  414.             #BREAK                               #! AND quit Processing
  415.           #ENDIF                                 #! END (IF Linked Field =...)
  416.         #ENDIF                                   #! END (IF Linked Field Exists...)
  417.       #ENDFOR                                    #! END (FOR Key Fields...)
  418.     #ENDIF                                       #! END (If Many:1...)
  419.   #ENDIF                                         #! END (If Valid Relation)
  420. #ELSIF(%LocateField)                             #! ELSE (IF LocateField provided)
  421.   #FOR(%File)                                    #! Search through each file
  422.     #FIX(%Field,%LocateField)                    #! Attempt to fix field
  423.     #IF(%Field)                                  #! IF FIX successful
  424.       #SET(%LookupFromFile,%File)                #! Save Current File
  425.       #FIX(%Field,%ScreenFieldUse)               #! FIX back to screen field
  426.       #FIX(%File,%FieldFile)                     #! FIX back to file
  427.       #FIX(%Relation,%LookupFromFile)            #! FIX relation to saved value
  428.       #SET(%LookupFromFile,%Null)                #! Clear Flag
  429.       #IF(%Relation)                             #! If return value field file
  430.         #IF(%RelationType='MANY:1')              #! IF the Relation is Many:1
  431.           #FOR(%RelationKeyField)                #! Cycle through Key Fields
  432.             #IF(UPPER(%RelationKeyFieldLink)=UPPER(%ScreenFieldUse)) #!If Linked Field=Screen Field
  433.               #IF(UPPER(%RelationKeyField)=UPPER(%LocateField))#! If Linked Field = Locate Field
  434.                 #SET(%LookupFromFile,%Relation)  #! Flag RelatedFile
  435.                 #SET(%LookupFromField,%LocateField) #!Flag Related Field
  436.                 #BREAK                           #! AND quit Processing
  437.               #ENDIF                             #! END (IF Linked Field =...)
  438.             #ENDIF                               #! END (IF Linked Field Exists...)
  439.           #ENDFOR                                #! END (FOR Key Fields...)
  440.         #ENDIF                                   #! END (If Many:1...)
  441.       #ENDIF                                     #! END (If Valid Relation)
  442.       #BREAK                                     #! QUIT Processing Files
  443.     #ENDIF                                       #! END (IF FIX...)
  444.   #ENDFOR                                        #! END (Searching Files)
  445.   #FIX(%Field,%ScreenFieldUse)                   #! FIX back to screen field
  446.   #FIX(%File,%FieldFile)                         #! FIX back to file
  447. #ENDIF                                           #! END (If Must Be...)
  448. #!***************************************************************************
  449. #GROUP(%RangeCode)                               #!Value Range Validation
  450. #!
  451. #!┌────────────────────────────┤Template Group├────────────┬─────────────────┐
  452. #!│                               %RangeCode               │Version: 3007.000│
  453. #!├──────────────────────────────┤Description├─────────────┴─────────────────┤
  454. #!│Purpose:      Generates Range Validation Code                             │
  455. #!│Called From:  %ScreenEditRoutines                                         │
  456. #!│Assumptions:  None                                                        │
  457. #!│Inserts:      None                                                        │
  458. #!│Symbols Set:  None                                                        │
  459. #!│Notes:        None                                                        │
  460. #!├───────────────────────────────┤Comments├─────────────────────────────────┤
  461. #!│Version   Comments                                                        │
  462. #!│────────  ────────────────────────────────────────────────────────────────│
  463. #!│3007.000  Release of CDD3 version 3007 templates                          │
  464. #!└──────────────────────────────────────────────────────────────────────────┘
  465. #!
  466. IF KEYCODE() <> EscKey                           #<! IF user didn't escape
  467. #IF(%FieldRangeLow = %NULL)                      #! If No Low Value provided
  468.   IF %ScreenFieldUse > %FieldRangeHigh           #<! IF field too high
  469.     #INSERT(%FieldValueTooHigh)                  #! Alert the User
  470. #ELSIF(%FieldRangeHigh = %NULL)                  #! ELSE (No High Value provided)
  471.   IF %ScreenFieldUse < %FieldRangeLow            #<! IF field too low
  472.     #INSERT(%FieldValueTooLow)                   #! Alert the User
  473. #ELSE                                            #! ELSE (High and Low provided)
  474.   IF ~INRANGE(%ScreenFieldUse,%FieldRangeLow,%FieldRangeHigh)#<! IF field out of range
  475.     #INSERT(%FieldValueOutOfRange)               #! Alert the User
  476. #ENDIF                                           #! END (If FieldRangeLow...)
  477.     SELECT(%ScreenField)                         #<! Select the same field
  478.     CYCLE                                        #<! and repeat the process
  479.   END                                            #<! END (If bad range value)
  480. END                                              #<! END (If user didn't esc)
  481. #!***************************************************************************
  482. #GROUP(%FieldLookupCode)                         #!Relation Validation Code
  483. #!
  484. #!┌────────────────────────────┤Template Group├────────────┬─────────────────┐
  485. #!│                            %FieldLookupCode            │Version: 3007.000│
  486. #!├──────────────────────────────┤Description├─────────────┴─────────────────┤
  487. #!│Purpose:      generates Post-Edit Must-Be-In-File field validation        │
  488. #!│Called From:  %ScreenEditRoutines                                         │
  489. #!│Assumptions:  None                                                        │
  490. #!│Inserts:      None                                                        │
  491. #!│Symbols Set:  None                                                        │
  492. #!│Notes:        None                                                        │
  493. #!├───────────────────────────────┤Comments├─────────────────────────────────┤
  494. #!│Version   Comments                                                        │
  495. #!│────────  ────────────────────────────────────────────────────────────────│
  496. #!│3007.000  Release of CDD3 version 3007 templates                          │
  497. #!└──────────────────────────────────────────────────────────────────────────┘
  498. #!
  499. #FIX(%Field,%ScreenFieldUse)                     #! FIX to process Field
  500. #FIX(%File,%FieldFile)                           #! FIX to process File
  501. #FIX(%Relation,%FieldLookup)                     #! FIX to process Relation
  502. #IF(%RelationType = 'MANY:1')                    #! IF a MANY:1 Relation
  503. IF KEYCODE() <> EscKey                           #<! IF user didn't escape
  504.   #FOR(%RelationKeyField)                        #! FOR each relation key field
  505.   %RelationKeyField = %RelationKeyFieldLink      #<! Assign linking field value
  506.   #ENDFOR                                        #! END (FOR each relation...)
  507.   GET(%Relation,%RelationKey)                    #<! Lookup record
  508.   IF ERRORCODE()                                 #<! If GET did not succeed ?
  509.   #FIX(%File,%FieldLookup)                       #! FIX to process Relation as File
  510.     CLEAR(%FilePre:Record)                       #<! Clear record if unsuccessful
  511.     #INSERT(%ParentRecordNotFound)               #! Alert the User
  512.     SELECT(%ScreenField)                         #<! Reselect the screen field
  513.   ELSE                                           #<! Else IF Errorcode
  514.     DISPLAY                                      #<! Update screen display
  515.   END                                            #<! End IF Errorcode
  516. END                                              #<! Not EscKey
  517. #ENDIF                                           #! END (IF Many:1)
  518. #!***************************************************************************
  519. #GROUP(%SetGenerationFlags)
  520. #!
  521. #!┌────────────────────────────┤Template Group├────────────┬─────────────────┐
  522. #!│                          %SetGenerationFlags           │Version: 3007.000│
  523. #!├──────────────────────────────┤Description├─────────────┴─────────────────┤
  524. #!│Purpose:      Sets flags to generate CASE SELECTED() and CASE FIELD()     │
  525. #!│              structures in main-body accept loops                        │
  526. #!│Called From:  Any procedure template that has a screen defined            │
  527. #!│Assumptions:  None                                                        │
  528. #!│Inserts:      None                                                        │
  529. #!│Symbols Set:  None                                                        │
  530. #!│Notes:        None                                                        │
  531. #!├───────────────────────────────┤Comments├─────────────────────────────────┤
  532. #!│Version   Comments                                                        │
  533. #!│────────  ────────────────────────────────────────────────────────────────│
  534. #!│3007.000  Release of CDD3 version 3007 templates                          │
  535. #!└──────────────────────────────────────────────────────────────────────────┘
  536. #!
  537. #SET(%SelectedCaseRequired,%Null)                #!
  538. #SET(%FieldCaseRequired,%Null)                   #!
  539. #SET(%HotKeyCaseRequired,%Null)
  540. #IF(%Screen)                                     #!
  541.   #FOR(%ScreenField)                             #!
  542.     #SET(%SearchButton,(UPPER(%ScreenField) & '?'))#!
  543.     #IF(%ScreenFieldSetup)                       #!
  544.       #SET(%SelectedCaseRequired,'TRUE')         #!
  545.     #ELSIF(INSTRING(%SearchButton,%SmartSelectedButtons,1,1))#!
  546.       #SET(%SelectedCaseRequired,'TRUE')         #!
  547.     #ENDIF                                       #!
  548.     #IF(NOT %FieldCaseRequired)                  #!
  549.       #IF(%ScreenFieldEdit)                      #!
  550.         #SET(%FieldCaseRequired,'TRUE')          #!
  551.       #ELSIF(INSTRING(%SearchButton,%SmartFieldButtons,1,1))#!
  552.         #SET(%FieldCaseRequired,'TRUE')          #!
  553.       #ELSIF(%FieldRangeLow)                     #!
  554.         #SET(%FieldCaseRequired,'TRUE')          #!
  555.       #ELSIF(%FieldRangeHigh)                    #!
  556.         #SET(%FieldCaseRequired,'TRUE')          #!
  557.       #ELSIF(%FieldLookup)                       #!
  558.         #SET(%FieldCaseRequired,'TRUE')          #!
  559.       #ENDIF                                     #!
  560.     #ENDIF                                       #!
  561.     #IF(%FieldCaseRequired AND %SelectedCaseRequired)
  562.       #BREAK                                     #!
  563.     #ENDIF                                       #!
  564.   #ENDFOR                                        #!
  565. #ENDIF                                           #!
  566. #IF(NOT %FieldCaseRequired)                      #!
  567.   #IF(%PullDown)                                 #!
  568.     #FOR(%PulldownField)                         #! add all procedure or
  569.       #IF(%PulldownFieldType = 'PROCEDURE')      #! source code calls
  570.         #SET(%FieldCaseRequired,'TRUE')          #!
  571.         #BREAK                                   #!
  572.       #ENDIF                                     #!
  573.     #ENDFOR                                      #!
  574.   #ENDIF                                         #!
  575. #ENDIF                                           #!
  576. #FOR(%HotKey)
  577.   #SET(%HotKeyCaseRequired,'TRUE')
  578.   #BREAK
  579. #ENDFOR
  580. #!***************************************************************************
  581. #CHAIN('BrwsGrps.TPX')
  582.