home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR2 / CLATPL.ZIP / CLARION5.TPX < prev    next >
Text File  |  1993-07-26  |  62KB  |  1,469 lines

  1. #!***************************************************************************
  2. #GROUP(%RelUpdate)                               #<!RelationalUpdate ROUTINE
  3.  
  4. #IF(%RelatedUpdateRoutine)
  5.  
  6. RelationalUpdate ROUTINE
  7.  AbortTransaction# = 0                           !Reset transaction indicator
  8.   #IF(%CascadeUpdate OR %ClearOnUpdate)
  9.       #SET(%SetFile,%Primary)
  10.   #IF(%NoLogoutSupport = %NULL)
  11.       #SET(%LogoutList,'LOGOUT(2')
  12.       #INSERT(%SetupLogout)
  13.       #Set(%Logoutlist,(%Logoutlist & ')'))
  14.  %LogoutList
  15.    #INSERT(%InitLogout)
  16.   #ENDIF
  17.       #SET(%SetFile,%Primary)
  18.         #IF(%RestrictUpdate)
  19.    DO CheckRestrictedUpdate                      #<!Check RESTRICT update
  20.    IF RestrictUpdate#                            #<!Restrict this update
  21.   #IF(%NoLogoutSupport = %NULL)
  22.      ROLLBACK                                    #<!Terminate the transaction
  23.   #ENDIF
  24.      EXIT                                        #<!Exit the update
  25.    END
  26.         #ENDIF
  27.    #INSERT(%RelationUpdate)
  28.  
  29.    PUT (%Primary)                                #<!Write the Parent record
  30.    #IF(%NoLogoutSupport = %NULL)
  31.    IF ~ERRORCODE()                               #<!If the Parent update is Ok
  32.     COMMIT                                       #<!Commit the transaction
  33.    ELSE                                          #<!else on any error
  34.     GLO:Message1 = 'Unable to complete the transaction'
  35.     GLO:Message2 = 'Error: ' & ERRORCODE() & ' ' & ERROR()
  36.     GLO:Message3 = 'Files have been restored to their original values'
  37.     ROLLBACK                                     #<!Rollback the transaction
  38.     ShowWarning                                  #<!Notify the user
  39.    END                                           #<!End IF ERRORCODE()
  40.    #ELSE                                         #! NoLogoutSupport
  41.    IF ERRORCODE()                                #<!Was the update ok?
  42.     GLO:Message1 = 'Unable to complete the Referential Update'
  43.     GLO:Message2 = 'Error: ' & ERRORCODE() & ' ' & ERROR()
  44.     GLO:Message3 = 'File: %Primary could not be updated !'
  45.     ShowWarning                                  #<!Notify the user
  46.    END
  47.    #ENDIF                                        !# NoLogoutSupport
  48.   #ELSE
  49.     #IF(%RestrictUpdate)
  50.    DO CheckRestrictedUpdate                      #<!Check RESTRICT update
  51.    IF RestrictUpdate#                            #<!Restrict this update
  52.      AbortTransaction# = 1                       #<!Turn AbortTransaction# ON
  53.      EXIT                                        #<!Exit the update
  54.    END
  55.     #ENDIF
  56.    PUT(%Primary)                                 #<!Write the Primary file
  57.   #ENDIF
  58. #ENDIF
  59. #!***************************************************************************
  60. #GROUP(%RelationUpdate)
  61. #FIX(%File,%SetFile)
  62. #FOR(%Relation)
  63. #IF(%RelationType = '1:MANY')
  64.     #IF(%RelationConstraintUpdate = 'CASCADE')
  65. #INSERT(%ClearCascadeUpdate)
  66.     #ELSIF(%RelationConstraintUpdate = 'CLEAR')
  67. #INSERT(%ClearCascadeUpdate)
  68.     #ENDIF
  69. #SET(%SetFile,%Relation)
  70. #INSERT(%RelationUpdate)
  71. #ENDIF
  72. #ENDFOR
  73. #!***************************************************************************
  74. #GROUP(%ClearCascadeUpdate)
  75.       #SET(%LinkToParent,%NULL)
  76.       #FOR(%RelationKeyField)
  77.       #IF(%RelationKeyFieldLink)
  78.        #SET(%TheLink,%RelationKeyFieldLink)
  79.        #IF(INSTRING(%TheLink,%LevelOneLinks,1,1) <> '0')
  80.         #SET(%LinkToParent,'TRUE')
  81.        #ENDIF
  82.        #IF(INSTRING(%TheLink,%LinkPool,1,1) <> '0')
  83.         #SET(%LinkToParent,'TRUE')
  84.        #ENDIF
  85.       #ENDIF
  86.       #ENDFOR
  87. #IF(%LinkToParent)
  88. #INSERT(%ChildCheck)
  89.   #FOR(%RelationKeyField)
  90.   #IF(%RelationKeyFieldLink <> %NULL)
  91.   IF %RelationKeyFieldLink <> %Relation:Lnk:%RelationKeyFieldLink #<!Has Link changed?
  92.     LinkFieldChged# = 1                          #<!Turn on LinkFieldChged#
  93.     UpdRelation = POSITION(%Relation)            #<!Save position of update
  94.   ELSE
  95.     CLEAR(UpdRelation)                           #<!Clear position variable
  96.   END
  97.   #ENDIF
  98.   #ENDFOR
  99.   IF LinkFieldChged#                              #<!did the LINK field change
  100.     SET(%RelationKey,%RelationKey)               #<!Set by key to related record
  101.     LOOP UNTIL EOF(%Relation)                    #<!Loop thru the file
  102.     #IF(%NoLogoutSupport)
  103.       HOLD(%Relation,10)                         #<!Set HOLD retry for 10 seconds
  104.     #ENDIF
  105.       NEXT(%Relation)                            #<!Read the record
  106.       DO CheckTransaction                        #<!Error check
  107.     #IF(%NoLogoutSupport = %NULL)
  108.       IF AbortTransaction# THEN EXIT.            #<!IF error EXIT
  109.     #ENDIF
  110.     #FOR(%RelationKeyField)
  111.     #IF(%RelationKeyFieldLink <> %NULL)
  112.       IF %RelationKeyField <> %Relation:Lnk:%RelationKeyFieldLink #<!Is this a related record?
  113.         BREAK                                    #<!Not related, BREAK from Loop
  114.       END                                        #<!End link field check
  115.     #ENDIF
  116.     #ENDFOR
  117.     #FOR(%RelationKeyField)
  118.     #IF(%RelationKeyFieldLink <> %NULL)
  119.       #IF(%RelationConstraintUpdate = 'CLEAR')
  120.       CLEAR(%RelationKeyField)                   #<!Enforce CLEAR constraint
  121.       #ELSIF(%RelationConstraintUpdate = 'CASCADE')
  122.       %RelationKeyField = %RelationKeyFieldLink #<!Enforce CASCADE constraint
  123.       #ENDIF
  124.     #ENDIF
  125.     #ENDFOR
  126.        PUT(%Relation)                            #<!Write the record
  127.        DO CheckTransaction                       #<!Check for an error
  128.     #IF(%NoLogoutSupport = %NULL)
  129.       IF AbortTransaction# THEN EXIT.            #<!IF error EXIT
  130.     #ENDIF
  131.     END                                          #<!End file process Loop
  132.     IF UpdRelation                               #<!Position of last update
  133.       RESET(%Relation,UpdRelation)               #<!Position to updated record
  134.       NEXT(%Relation)                            #<!read updated record into buffer
  135.     END                                          #<!End IF UpdRelation
  136.   END                                            #<!End IF LinkFieldChgd#
  137. END                                              #<!End IF record related?
  138. LinkFieldChged# = 0                              #<!Turn LinkFieldChged# OFF
  139. #ENDIF
  140. #!***************************************************************************
  141. #GROUP(%ChildCheck)
  142.   #FOR(%RelationKeyField)
  143.     #IF(%RelationKeyFieldLink <> %NULL)
  144. %RelationKeyField = %Relation:Lnk:%RelationKeyFieldLink #<!Prime access component
  145.     #ELSE
  146. CLEAR(%RelationKeyField)                         #<!CLEAR the NO LINK component
  147.     #ENDIF
  148.   #ENDFOR
  149. SET(%RelationKey,%RelationKey)                   #<!Set to record by key
  150. NEXT(%Relation)                                  #<!Read the record
  151. #SET(%Counter,%NULL)
  152.  #FOR(%RelationKeyField)
  153.    #IF(%RelationKeyFieldLink <> %NULL)
  154.     #SET(%Counter,(%Counter + 1))
  155.     #IF(%Counter = '1')
  156.      #SET(%IfLine,('IF '& %RelationKeyField &' = '& %Relation &':Lnk:' & %RelationKeyFieldLink))
  157.     #ELSE
  158.      #SET(%IfLine,(%IfLine & ' AND ' & %RelationKeyField &' = '& %Relation&':Lnk:' & %RelationKeyFieldLink))
  159.     #ENDIF
  160.    #ENDIF
  161.  #ENDFOR
  162. %IfLine                                          #<!Is this a related record?
  163. #!***************************************************************************
  164. #GROUP(%RestrictUpdateCheck)
  165.  
  166. CheckRestrictedUpdate ROUTINE
  167.   RestrictUpdate# = 0
  168.   SetWarning# = 0
  169. #FIX(%File,%Primary)
  170. #FOR(%Relation)
  171.  #IF(%RelationConstraintUpdate = 'RESTRICT')
  172.   #IF(%RelationType = '1:MANY')
  173.    #FOR(%RelationKeyField)
  174.      #IF(%RelationKeyFieldLink <> %NULL)
  175.   %RelationKeyField = %Relation:Lnk:%RelationKeyFieldLink #<!Prime the Key component
  176.      #ELSE
  177.   CLEAR(%RelationKeyField)                       #<!Clear this Key component
  178.      #ENDIF
  179.    #ENDFOR
  180.   SET(%RelationKey,%RelationKey)                 #<!Set to record by key
  181.   NEXT(%Relation)                                #<!Read the record
  182.   IF ERRORCODE()                                 #<!Was there an error?
  183.     IF ERRORCODE() = BadRecErr                   #<!Record Not Available
  184.    #FOR(%RelationKeyField)
  185.      #IF(%RelationKeyFieldLink <> %NULL)
  186.       CLEAR(%RelationKeyField)                   #<!Clear the component
  187.      #ENDIF
  188.    #ENDFOR
  189.     ELSE                                         #<!On any other error
  190.       GLO:Message1 = 'Unable to process the file: %Relation '
  191.       GLO:Message2 = 'Error: '& ERRORCODE() & ' ' & ERROR()
  192.       GLO:Message3 = 'The transaction cannot be completed'
  193.       ShowWarning                                #<!Notify the user
  194.       DISABLE(1,FIELDS())                        #<!Disable screen fields
  195.       ENABLE(?Cancel)                            #<!Enable the CANCEL button
  196.       RestrictUpdate# = 1                        #<!Turn on RestrictUpdate#
  197.       EXIT                                       #<!Exit the Routine
  198.     END                                          #<!End IF BadRecErr
  199.   END                                            #<!End IF ERRORCODE()
  200.   #SET(%Counter,%NULL)
  201.    #FOR(%RelationKeyField)
  202.      #IF(%RelationKeyFieldLink <> %NULL)
  203.       #SET(%Counter,(%Counter + 1))
  204.       #IF(%Counter = '1')
  205.        #SET(%IfLine,('IF '& %RelationKeyField &' = '& %Relation & ':Lnk:' & %RelationKeyFieldLink))
  206.       #ELSE
  207.        #SET(%IfLine,(%IfLine & ' AND ' & %RelationKeyField &' = '& %Relation & ':Lnk:' & %RelationKeyFieldLink))
  208.       #ENDIF
  209.      #ENDIF
  210.    #ENDFOR
  211.   %IfLine                                        #<!Compare Link field(s)
  212.     #INSERT(%RestrictUpdateCode)
  213.   END                                            #<!End related record check
  214.   #ENDIF
  215.  #ENDIF
  216. #ENDFOR
  217.   IF SetWarning#                                 #<!If SetWarning is ON
  218.     GLO:Message1 = 'This record is referenced from other file(s)'
  219.     GLO:Message2 = 'Link field(s) are RESTRICTED from change'
  220.     GLO:Message3 = ' and have been reset to original values '
  221.     ShowWarning                                  #<!Notify the user
  222.     DISPLAY                                      #<!Update the screen
  223.   END                                            #<!End SetWarning
  224.   EXIT                                           #<!Exit the routine
  225. #!***************************************************************************
  226. #GROUP(%RestrictUpdateCode)
  227. #FOR(%RelationKeyField)
  228. #IF(%RelationKeyFieldLink <> %NULL)
  229. IF %RelationKeyFieldLink <> %Relation:Lnk:%RelationKeyFieldLink #<!Parent restricted field
  230.   SetWarning# = 1                                #<!Turn on warning switch
  231.   RestrictUpdate# = 1                            #<!Turn on Restrict switch
  232.   %RelationKeyFieldLink = %Relation:Lnk:%RelationKeyFieldLink #<!Reset to original value
  233.   DISPLAY                                        #<!Refresh the screen
  234. END                                              #<!End field compare
  235. #ENDIF
  236. #ENDFOR
  237. #!***************************************************************************
  238. #GROUP(%ConcurrentWrite)
  239. #IF(%ConcurrentWriteOn)
  240.  
  241. ConcurrentWrite ROUTINE
  242.  AbortWrite# = 0                                 #<!Initialize AbortWrite#
  243.  IF ~AutoIncAdd                                  #<!Not an Autoincrement ADD
  244.    Sav:SaveRecord = %FilePre:Record              #<!Save Record to the Queue
  245.    #IF(%MemoChk)
  246.    #FOR(%Field)
  247.    #IF(%FieldType = 'MEMO')
  248.    SAV:%FieldID   = %Field                       #<!Save Memo to the Queue
  249.    #ENDIF
  250.    #ENDFOR
  251.    #ENDIF
  252.    ADD(RecordQueue,2)                            #<!Add the changed record
  253.    GET(RecordQueue,1)                            #<!Get the original record
  254.    RESET(%Primary,SavePointer)                   #<!Position to record on disk
  255.    HOLD(%Primary,2)                              #<!Set HOLD retry for 2 seconds
  256.    NEXT(%Primary)                                #<!Read the record into buffer
  257.    IF ERRORCODE()                                #<!Was there an error?
  258.      CASE ERRORCODE()                            #<!Process recoverable errors
  259.        OF IsHeldErr                              #<!Record is already held
  260.          GLO:Message1 = 'The Record is locked by another workstation '
  261.          GLO:Message2 = 'when you return to the entry FORM choose OK '
  262.          GLO:Message3 = 'to try the update again, or CANCEL to abort '
  263.          ShowWarning                             #<!Show user a warning
  264.          SELECT(1)                               #<!Place cursor on 1st field
  265.          RELEASE(%Primary)                       #<!Release the HOLD
  266.          AbortWrite# = 1                         #<!Turn on AbortWrite#
  267.          EXIT                                    #<!Back to main Loop
  268.        ELSE                                      #<!On any other error
  269.          IF DiskError('File Access Error')       #<!Call the Diskerror function
  270.            RELEASE(%Primary)                     #<!Release the hold
  271.            FREE(RecordQueue)                     #<!Free the memory Queue
  272.            DISABLE(1,FIELDS())                   #<!Disable all screen fields
  273.            ENABLE(?Cancel)                       #<!Enable the Cancel button
  274.            SELECT(?Cancel)                       #<!Place cursor on Cancel
  275.            AbortWrite# = 1                       #<!Turn on AbortWrite#
  276.            EXIT                                  #<!and exit the routine
  277.          END                                     #<!End IF Diskerror
  278.      END                                         #<!End CASE Errorcode()
  279.    ELSIF Sav:SaveRecord <> %FilePre:Record       #<!Has the record been changed
  280.      Sav:SaveRecord = %FilePre:Record            #<!Then update the Queue record
  281.      #IF(%MemoChk = 'TRUE')
  282.      #FOR(%Field)
  283.      #IF(%FieldType = 'MEMO')
  284.      IF SAV:%FieldID <> %Field                   #<!Has the Memo been changed?
  285.        SAV:%FieldID = %Field                     #<!Then update the Queue memo
  286.      END                                         #<!End IF Memo changed
  287.      #ENDIF
  288.      #ENDFOR
  289.      #ENDIF
  290.      #INSERT(%ConflictUpdate)
  291.    #IF(%MemoChk = 'TRUE')
  292.      #FOR(%Field)
  293.      #IF(%FieldType = 'MEMO')
  294.    ELSIF SAV:%FieldID <> %Field                  #<!Has the Memo been changed?
  295.      SAV:%FieldID = %Field                       #<!Then update the Queue memo
  296.      #INSERT(%ConflictUpdate)
  297.      #ENDIF
  298.      #ENDFOR
  299.    #ENDIF
  300.    ELSE                                          #<!Its ok to update the file
  301.      GET(RecordQueue,2)                          #<!Retrieve the users changes
  302.      %FilePre:Record = Sav:SaveRecord            #<!Move changes to record buffer
  303.      #IF(%MemoChk)
  304.      #FOR(%Field)
  305.      #IF(%FieldType = 'MEMO')
  306.      %Field = SAV:%FieldID                       #<!Move Memo to buffer
  307.      #ENDIF
  308.      #ENDFOR
  309.      #ENDIF
  310.    END                                           #<!End IF Errorcode()
  311.  END                                             #<!End IF ~AutoIncAdd
  312.  #ENDIF
  313. #!***************************************************************************
  314. #GROUP(%RelDelete)                               #<!RealationalDelete ROUTINE
  315.  
  316. #IF(%RelatedDeleteRoutine)
  317. RelationalDelete ROUTINE
  318.       #SET(%SetFile,%Primary)
  319.   #IF(%NoLogoutSupport = %NULL)
  320.       #SET(%LogoutList,'LOGOUT(2')
  321.       #INSERT(%SetupLogoutDel)
  322.       #Set(%Logoutlist,(%Logoutlist & ')'))
  323.   %LogoutList
  324.     #INSERT(%InitLogout)
  325.   #ENDIF
  326.       #SET(%SetFile,%Primary)
  327.     #INSERT(%RelationDelete)
  328.     #IF(%CascadeDelete OR %ClearOnDelete)
  329.     DELETE(%Primary)                             #<!Delete record Primary file
  330.     #INSERT(%CommitCheck)
  331.     #ELSE
  332.     DELETE(%Primary)                             #<!Delete record Primary file
  333.     #ENDIF
  334. #ENDIF
  335. #!***************************************************************************
  336. #GROUP(%RelationDelete)
  337. #FIX(%File,%SetFile)
  338. #FOR(%Relation)
  339. #IF(%RelationType = '1:MANY')
  340.     #IF(%RelationConstraintDelete = 'CASCADE')
  341. #INSERT(%ClearCascadeDelete)
  342.     #ELSIF(%RelationConstraintDelete = 'CLEAR')
  343. #INSERT(%ClearCascadeDelete)
  344.     #ENDIF
  345. #SET(%SetFile,%Relation)
  346. #INSERT(%RelationDelete)
  347. #ENDIF
  348. #ENDFOR
  349. #!***************************************************************************
  350. #GROUP(%ClearCascadeDelete)
  351. #INSERT(%ChildCheck)
  352.   SET(%RelationKey,%RelationKey)                 #<!Set to first occurence
  353.     LOOP UNTIL EOF(%Relation)                    #<!Loop thru the file
  354.     #IF(%NoLogoutSupport)
  355.       HOLD(%Relation,10)                         #<!Set HOLD retry for 10 seconds
  356.     #ENDIF
  357.       NEXT(%Relation)                            #<!Read the record
  358.       DO CheckTransaction                        #<!Check for error
  359.     #IF(%NoLogoutSupport = %NULL)
  360.       IF AbortTransaction# THEN  EXIT.           #<!IF error exit the routine
  361.     #ENDIF
  362.     #FOR(%RelationKeyField)
  363.     #IF(%RelationKeyFieldLink <> %NULL)
  364.       IF %RelationKeyField <> %Relation:Lnk:%RelationKeyFieldLink #<!Is this a related record?
  365.         BREAK                                    #<!Not Related, BREAK from Loop
  366.       END
  367.       #IF(%RelationConstraintDelete = 'CLEAR')
  368.       CLEAR(%RelationKeyField)                   #<!Enforce the relation constraint
  369.       #ENDIF
  370.     #ENDIF
  371.     #ENDFOR
  372.       #IF(%RelationConstraintDelete = 'CLEAR')
  373.       PUT(%Relation)                             #<!Enforce CLEAR constraint
  374.       #ELSIF(%RelationConstraintDelete = 'CASCADE')
  375.       DELETE(%Relation)                          #<!Enforce CASCADE constraint
  376.       #ENDIF
  377.       DO CheckTransaction
  378.     #IF(%NoLogoutSupport = %NULL)
  379.       IF AbortTransaction# THEN EXIT.
  380.     #ENDIF
  381.     END                                          #<!End Loop
  382. END                                              #<!Is record related?
  383. #!***************************************************************************
  384. #GROUP(%RestrictDeleteCode)
  385.  
  386. CheckRestrictedDelete ROUTINE
  387.   RestrictDelete# = 0                            ! Reset restrict flag
  388. #FIX(%File,%Primary)
  389. #FOR(%Relation)
  390.  #IF(%RelationConstraintDelete = 'RESTRICT')
  391.   #IF(%RelationType = '1:MANY')
  392.    #FOR(%RelationKeyField)
  393.      #IF(%RelationKeyFieldLink <> %NULL)
  394.   %RelationKeyField = %Relation:Lnk:%RelationKeyFieldLink #<!Prime the Key component
  395.      #ELSE
  396.   CLEAR(%RelationKeyField)                       #<!Clear this Key component
  397.      #ENDIF
  398.    #ENDFOR
  399.   SET(%RelationKey,%RelationKey)                 #<!Set to record by key
  400.   NEXT(%Relation)                                #<!Read the record
  401.   IF ERRORCODE()                                 #<!Was there an error?
  402.     IF ERRORCODE() = BadRecErr                   #<!If Record Not Available
  403.    #FOR(%RelationKeyField)
  404.      #IF(%RelationKeyFieldLink <> %NULL)
  405.       CLEAR(%RelationKeyField)                   #<!Clear the component
  406.      #ENDIF
  407.    #ENDFOR
  408.     ELSE                                         #<!On any other error
  409.       GLO:Message1 = 'Unable to process the file: %Relation '
  410.       GLO:Message2 = 'Error: '& ERRORCODE() & ' ' & ERROR()
  411.       GLO:Message3 = 'The transaction cannot be completed'
  412.       ShowWarning                                #<!Notify the user
  413.       DISABLE(1,FIELDS())                        #<!Disable screen fields
  414.       ENABLE(?Cancel)                            #<!Enable the CANCEL button
  415.       RestrictDelete# = 1                        #<!Turn on RestrictDelete#
  416.       EXIT                                       #<!Exit the Routine
  417.     END                                          #<!End IF BadRecErr
  418.   END                                            #<!End IF ERRORCODE()
  419.   #SET(%Counter,%NULL)
  420.    #FOR(%RelationKeyField)
  421.      #IF(%RelationKeyFieldLink <> %NULL)
  422.       #SET(%Counter,(%Counter + 1))
  423.       #IF(%Counter = '1')
  424.        #SET(%IfLine,('IF '& %RelationKeyField &' = '& %RelationKeyFieldLink))
  425.       #ELSE
  426.        #SET(%IfLine,(%IfLine & ' AND ' & %RelationKeyField &' = '& %RelationKeyFieldLink))
  427.       #ENDIF
  428.      #ENDIF
  429.    #ENDFOR
  430.   %IfLine
  431.     GLO:Message1 = 'This record is restricted from deletion'
  432.     GLO:Message2 = 'It is referenced from other files'
  433.     ShowWarning                                  #<!Notify the user
  434.     DISABLE(1,FIELDS())                          #<!Disable screen fields
  435.     ENABLE(?Cancel)                              #<!Enable the CANCEL button
  436.     RestrictDelete# = 1                          #<!Turn on RestrictDelete#
  437.     EXIT                                         #<!Exit the routine
  438.   END                                            #<!End error check
  439.   #ENDIF
  440.  #ENDIF
  441. #ENDFOR
  442.   EXIT                                           #<!Exit the Routine
  443. #!***************************************************************************
  444. #GROUP(%SetupLogout)
  445. #FIX(%File,%SetFile)
  446. #FOR(%Relation)
  447. #IF(%RelationType = '1:MANY')
  448.     #IF(%RelationConstraintUpdate = 'CASCADE')
  449.      #SET(%Temp, %Relation)
  450.      #IF(INSTRING(%%Temp,%LogoutList,1,1) = '0')
  451.       #SET(%Logoutlist,(%Logoutlist &','& %Temp))
  452.      #ENDIF
  453.     #ELSIF(%RelationConstraintUpdate = 'CLEAR')
  454.      #SET(%Temp, %Relation)
  455.      #IF(INSTRING(%%Temp,%LogoutList,1,1) = '0')
  456.       #SET(%Logoutlist,(%Logoutlist &','& %Temp))
  457.      #ENDIF
  458.     #ELSIF(%RelationConstraintUpdate = 'RESTRICT')
  459.      #SET(%Temp, %Relation)
  460.      #IF(INSTRING(%%Temp,%LogoutList,1,1) = '0')
  461.       #SET(%Logoutlist,(%Logoutlist &','& %Temp))
  462.      #ENDIF
  463.     #ENDIF
  464. #SET(%SetFile,%Relation)
  465. #INSERT(%SetupLogout)
  466. #ENDIF
  467. #ENDFOR
  468. #!***************************************************************************
  469. #GROUP(%SetupLogoutDel)
  470. #FIX(%File,%SetFile)
  471. #FOR(%Relation)
  472. #IF(%RelationType = '1:MANY')
  473.     #IF(%RelationConstraintDelete = 'CASCADE')
  474.       #SET(%Temp, %Relation)
  475.       #IF(INSTRING(%%Temp,%LogoutList,1,1) = '0')
  476.         #SET(%Logoutlist,(%Logoutlist &','& %Temp))
  477.       #ENDIF
  478.     #ELSIF(%RelationConstraintDelete = 'CLEAR')
  479.       #SET(%Temp, %Relation)
  480.       #IF(INSTRING(%%Temp,%LogoutList,1,1) = '0')
  481.         #SET(%Logoutlist,(%Logoutlist &','& %Temp))
  482.       #ENDIF
  483.     #ELSIF(%RelationConstraintDelete = 'RESTRICT')
  484.       #SET(%Temp, %Relation)
  485.       #IF(INSTRING(%%Temp,%LogoutList,1,1) = '0')
  486.         #SET(%Logoutlist,(%Logoutlist &','& %Temp))
  487.       #ENDIF
  488.     #ENDIF
  489. #SET(%SetFile,%Relation)
  490. #INSERT(%SetupLogoutDel)
  491. #ENDIF
  492. #ENDFOR
  493. #!***************************************************************************
  494. #GROUP(%InitLogout)
  495. IF ERRORCODE()                                   #<!Was Logout OK?
  496.   AbortTransaction# = 1                          #<!Turn AbortTransaction ON
  497.   CASE ERRORCODE()                               #<!Process recoverable error
  498.     OF IsLockedErr                               #<!Was the file locked?
  499.       GLO:Message1 = 'The transaction cannot be completed'
  500.       GLO:Message2 = 'at this time.  One or more of the files'
  501.       GLO:Message3 = 'is already locked.  You may retry the operation'
  502.       ROLLBACK                                   #<!End LOGOUT
  503.       ShowWarning                                #<!Notify the user
  504.       SELECT(?Ok)                                #<!Place cursor on OK
  505.       EXIT                                       #<!Exit the Routine
  506.     ELSE                                         #<!Any other error
  507.       GLO:Message1 = 'The transaction cannot be completed'
  508.       GLO:Message2 = 'at this time.  The error posted was: '
  509.       GLO:Message3 = ERROR()
  510.       ROLLBACK                                   #<!End LOGOUT
  511.       ShowWarning                                #<!Notify the user
  512.       DISABLE(1,FIELDS())                        #<!Disable the screen fields
  513.       ENABLE(?Cancel)                            #<!Enable the Cancel button
  514.       SELECT(?Cancel)                            #<!Place the cursor on Cancel
  515.       EXIT                                       #<!Exit the Routine
  516.   END                                            #<!End CASE errorcode
  517. END                                              #<!No errors, start transaction
  518. AbortTransaction# = 0                            #<!Set Abort switch to off
  519. #!***************************************************************************
  520. #GROUP(%ConcurrentDelete)
  521. #IF(%ConcurrentDeleteOn)
  522.  
  523. ConcurrentDelete ROUTINE
  524.   AbortDelete# = 0
  525.   RESET(%Primary,SavePointer)                    #<!Set position in Primary file
  526.   HOLD(%Primary,2)                               #<!Hold the record
  527.   NEXT(%Primary)                                 #<!Read the record into buffer
  528.   IF POSITION(%Primary) <> SavePointer           #<!Is the record already deleted?
  529.     RELEASE(%Primary)                            #<!Relase record Hold
  530.     FREE(RecordQueue)                            #<!Free the memory Queue
  531.     #IF(%PullDownStructure)
  532.     CLOSE(%PullDown)
  533.     #ENDIF
  534.     RETURN                                       #<!Return to the calling procedure
  535.   END                                            #<!End IF position check
  536.   IF ERRORCODE()                                 #<!Check for file access error
  537.     CASE ERRORCODE()                             #<!Case for recoverable errors
  538.       OF IsHeldErr                               #<!Record is already held
  539.         GLO:Message1 = 'The Record is locked by another workstation '
  540.         GLO:Message2 = 'when you return to the entry FORM choose OK '
  541.         GLO:Message3 = 'to try the update again, or CANCEL to abort '
  542.         ShowWarning                              #<!Notify the user
  543.         SELECT(1)                                #<!Place cursor on 1st field
  544.         RELEASE(%Primary)                        #<!Release HOLD request
  545.         AbortDelete# = 1                         #<!Set AbortDelete# ON
  546.         EXIT                                     #<!Re-start main LOOP
  547.       ELSE                                       #<!for any other error
  548.         IF DiskError('Unable to process current Record') #<!Call error function
  549.           GLO:Message2 = 'Unable to continue, Press OK to exit'
  550.           ShowWarning                            #<!Notify the user
  551.           #IF(SharedFiles = 'TRUE')
  552.           FREE(RecordQueue)                      #<!Free the memory queue
  553.           #ENDIF
  554.           #IF(%PullDownStructure)
  555.           CLOSE(%PullDown)
  556.           #ENDIF
  557.           RETURN                                 #<!Return to calling procedure
  558.         END                                      #<!End IF Diskerror
  559.     END                                          #<!End CASE errorcode
  560.   END                                            #<!End IF errorcode()
  561. #ENDIF
  562. #!***************************************************************************
  563. #GROUP(%CheckTransaction)
  564.  
  565. CheckTransaction ROUTINE
  566.   IF ERRORCODE()
  567.   #IF(%NoLogoutSupport = %NULL)
  568.     AbortTransaction# = 1
  569.     GLO:Message1 = 'The transaction cannot be completed'
  570.     GLO:Message2 = 'Error: '&ERROR()
  571.     GLO:Message3 = 'Files will be restored to original values'
  572.     ROLLBACK                                     #<!Restore original records
  573.     ShowWarning                                  #<!Notify the user
  574.     DISABLE(1,FIELDS())                          #<!Disable all screen fields
  575.     ENABLE(?Cancel)                              #<!Activate the Cancel button
  576.     SELECT(?Cancel)                              #<!Place the cursor on Cancel
  577.     IF ERRORCODE() <> NoDriverSupport
  578.       GLO:Message1 = 'Files could not be restored to original values'
  579.       GLO:Message2 = 'Error: '&ERROR()
  580.       ShowWarning                                #<!Notify the user
  581.     END
  582.   END                                            #<!End error check
  583.   #ELSE                                          #! NoLogoutSupport
  584.     GLO:Message1 = 'The Referential Update/Delete encountered an error'
  585.     GLO:Message2 = 'Error: '& ERRORCODE() & ' ' & ERROR()
  586.     GLO:Message3 = 'Relational integrity for: ' & ERRORFILE() & 'is suspect'
  587.     ShowWarning                                  #<!Notify the user
  588.   END
  589.   #ENDIF
  590. #!***************************************************************************
  591. #GROUP(%RelUpdSave)
  592.  
  593. RelationAccessSave ROUTINE
  594. #SET(%SetFile,%Primary)
  595. #INSERT(%RelUpdateSave)
  596. #!***************************************************************************
  597. #GROUP(%RelUpdateSave)
  598. #FIX(%File,%SetFile)
  599. #FOR(%Relation)
  600.     #IF(%RelationType = '1:MANY')
  601.       #IF(%CloseFiles)                          #!Generate function for close
  602.    %Relation::Opened = CheckOpen(%Relation)    #<!Ensure %Relation file is open
  603.       #ELSE
  604.    CheckOpen(%Relation)                        #<!Ensure %Relation file is open
  605.       #ENDIF
  606.   #SET(%SetFile,%Relation)
  607.   #INSERT(%ChildSave)
  608. #INSERT(%RelUpdateSave)
  609.     #ENDIF
  610. #ENDFOR
  611. #!***************************************************************************
  612. #GROUP(%ChildSave)
  613.   #FOR(%RelationKeyField)
  614.     #IF(%RelationKeyFieldLink <> %NULL)
  615.   #IF(INSTRING(%SetFile,%LevelOne,1,1) <> '0')
  616. %Relation:Lnk:%RelationKeyFieldLink = %RelationKeyFieldLink #<!save original link
  617. %RelationKeyField = %RelationKeyFieldLink        #<!Prime key component
  618.   #ELSE
  619.   #SET(%SaveLine,(%RelationKeyField &' <> '& %RelationKeyFieldLink))
  620. %Relation:Lnk:%RelationKeyFieldLink = %RelationKeyFieldLink #<!save original link
  621. %RelationKeyField = %RelationKeyFieldLink        #<!Prime key component
  622.   #ENDIF
  623.     #ELSE
  624. CLEAR(%RelationKeyField)                         #<!Clear NoLink field
  625.     #ENDIF
  626.   #ENDFOR
  627. SET(%RelationKey,%RelationKey)                   #<!Set by RelationAccess Key
  628. NEXT(%Relation)                                  #<!Read the record
  629. #FOR(%RelationKeyField)
  630.   #IF(%RelationKeyFieldLink <> %NULL)
  631. IF %RelationKeyField <> %RelationKeyFieldLink    #<!Is the record related?
  632.    NotRelated# = 1                                  #<!No, then set NotRelated# ON
  633. END
  634.   #ENDIF
  635. #ENDFOR
  636. IF ERRORCODE() OR NotRelated#                       #<!Check error or not related
  637.   #FIX(%File,%Relation)
  638.   CLEAR(%FilePre:Record)                         #<!Clear the record if needed
  639. END                                              #<!End IF Errorcode
  640. #!***************************************************************************
  641. #GROUP(%InitQue)
  642. #IF(%SharedFiles = 'TRUE')
  643.  
  644. InitializeQueue ROUTINE                          #<!save initial record values
  645.   Sav:SaveRecord = %FilePre:Record               #<!Save the current record
  646.   #IF(%MemoChk)
  647.   #FOR(%Field)
  648.   #IF(%FieldType = 'MEMO')
  649.   SAV:%FieldID   = %Field                        #<!Save the memo
  650.   #ENDIF
  651.   #ENDFOR
  652.   #ENDIF
  653.   ADD(RecordQueue,1)                             #<!add record to Queue
  654.   ADD(RecordQueue,2)                             #<!add record again
  655.   IF ERRORCODE()                                 #<!check Queue add error
  656.     CASE ERRORCODE()
  657.       OF NoMemErr                                #<!Is there enough memory?
  658.       GLO:Message1 = 'Not Enough Memory to proceed'
  659.       GLO:Message2 = 'with this operation . . . . '
  660.       ShowWarning                                #<!Notify the user
  661.       DISABLE(1,FIELDS())                        #<!Disable the screen fields
  662.       ENABLE(?Cancel)                            #<!Enable the Cancel button
  663.       SELECT(?Cancel)                            #<!Place cursor on Cancel
  664.       DISPLAY                                    #<!Update screen display
  665.     ELSE                                         #<!On any other error
  666.       GLO:Message1 = ERRORCODE() & ' ' & ERROR()
  667.       GLO:Message2 = 'Unable to continue . . . .'
  668.       ShowWarning                                #<!Show user the error
  669.       DISABLE(1,FIELDS())                        #<!Disable screen fields
  670.       ENABLE(?Cancel)                            #<!Enable Cancel button
  671.       SELECT(?Cancel)                            #<!Place cursor on Cancel
  672.       DISPLAY                                    #<!re-display the screen
  673.     END                                          #<!End CASE Errorcode
  674.   END                                            #<!End IF Errorcode
  675. #ENDIF
  676. #!***************************************************************************
  677. #GROUP(%InitFields)
  678. #IF(%InitRoutine = 'TRUE')
  679.  
  680. InitializeFields ROUTINE
  681. #FOR(%Field)
  682. #IF(%FieldInitial <> %NULL)
  683.    %Field = %FieldInitial
  684. #ENDIF
  685. #ENDFOR
  686. #ENDIF
  687. #!***************************************************************************
  688. #GROUP(%SecondaryLookups)
  689.  
  690. SecondaryLookups ROUTINE
  691.   #INSERT(%GetSecondaryRecords)                  #<!Lookup into Secondary files
  692.   #FOR(%Secondary)                              #! for fields in the list box
  693.       #IF(%SecondaryType = 'MANY:1')            #!Check for lookup files
  694.         #FIX(%File,%SecondaryTo)
  695.         #FIX(%Relation,%Secondary)
  696.         #FOR(%RelationKeyField)
  697.   DISPLAY(%RelationKeyField)
  698.         #ENDFOR
  699.       #ENDIF
  700.   #ENDFOR
  701. #!***************************************************************************
  702. #GROUP(%InsertMessage)
  703. #IF(%InsertMsg <> %NULL)
  704. LOC:Message = CENTER('%InsertMsg',SIZE(LOC:Message)) #<!Assign ADD message
  705. #ELSE
  706. LOC:Message = CENTER(GLO:InsertMsg,SIZE(LOC:Message))#<!Assign ADD message
  707. #ENDIF
  708. #!***************************************************************************
  709. #GROUP(%ChangeMessage)
  710. #IF(%ChangeMsg <> %NULL)
  711. LOC:Message = CENTER('%ChangeMsg',SIZE(LOC:Message)) #<!Assign CHANGE message
  712. #ELSE
  713. LOC:Message = CENTER(GLO:ChangeMsg,SIZE(LOC:Message))#<!Assign CHANGE message
  714. #ENDIF
  715. #!***************************************************************************
  716. #GROUP(%DeleteMessage)
  717. #IF(%DeleteMsg <> %NULL)
  718. LOC:Message = CENTER('%DeleteMsg',SIZE(LOC:Message)) #<!Assign DELETE message
  719. #ELSE
  720. LOC:Message = CENTER(GLO:DeleteMsg,SIZE(LOC:Message))#<!Assign DELETE message
  721. #ENDIF
  722. #!***************************************************************************
  723. #GROUP(%AutoIncCode)
  724. #IF(%AutoInc = 'TRUE')
  725.  
  726. AutoNumber Routine
  727.   LOOP                                            #<!Loop for autonumbering
  728.    #FIX(%File,%Primary)
  729. #FOR(%Key)
  730.  #IF(%KeyAuto)                                   #! <> %NULL
  731.      #FOR(%KeyField)
  732.       #FIX(%Field,%KeyField)
  733.       #IF(UPPER(%FieldType) = 'PICTURE')         #!Autonumber Picture data type
  734.         #IF(INSTRING('@N',UPPER(%FieldRecordPicture),1,1)) #!If its an @n picture
  735.    %KeyField = ALL('9')                          #<!Fill strings with 9's
  736.         #ELSE
  737.    CLEAR(%KeyField,1)                            #<!Clear Ascending to high value
  738.         #ENDIF
  739.       #ELSE
  740.    CLEAR(%KeyField,1)                            #<!Clear Ascending to high value
  741.       #ENDIF
  742.      #ENDFOR
  743.    #FOR(%Formula)
  744.     #IF(UPPER(%FormulaClass) = 'PRIMEKEY')
  745.    #INSERT(%GenerateFormula)
  746.     #ENDIF
  747.    #ENDFOR
  748.    #IF(%PrimeKeysExist)
  749.       #FOR(%KeyField)
  750.        #IF(%KeyField <> %KeyAuto)
  751.    Prime::%KeyField = %KeyField                 #<!Save for Subset numbering
  752.        #ENDIF
  753.       #ENDFOR
  754.    #ENDIF
  755.    SET(%Key,%Key)                                #<!For each autoincrement key
  756.    PREVIOUS(%Primary)                            #<!Read last record (Ascending)
  757.    IF ERRORCODE() = BadRecErr                    #<!If Errorcode No Records
  758.      %KeyAuto:AutoInc# = 1                       #<!then start numbering at 1
  759.    ELSIF ERRORCODE()                             #<!On any other error
  760.        GLO:Message1 = 'Unable to READ keyed record'
  761.        GLO:Message2 = 'Cannot continue update....'
  762.        GLO:Message3 = 'Error: '&ERRORCODE() & ' ' & ERROR()
  763.        ShowWarning                               #<!Show user the error
  764.        #IF(%PullDownStructure)
  765.        CLOSE(%PullDown)
  766.        #ENDIF
  767.        RETURN                                    #<!and return to caller
  768.    ELSE
  769.    #IF(%PrimeKeysExist)
  770.    #SET(%Pass,'1')
  771.       #FOR(%KeyField)
  772.        #IF(%KeyField <> %KeyAuto)
  773.         #IF(%Pass = '1')
  774.    #SET(%MatchSubset,('IF ' & 'Prime::'& %KeyField & ' = ' & %KeyField))
  775.         #ELSE
  776.    #SET(%MatchSubset,(%MatchSubset & ' AND ' & 'Prime::'& %KeyField & ' = ' & %KeyField))
  777.         #ENDIF
  778.         #SET(%Pass,(%Pass + 1))
  779.        #ENDIF
  780.       #ENDFOR
  781.     %MatchSubset
  782.       %KeyAuto:AutoInc# = %KeyAuto + 1           #<!Subset incremented value
  783.     ELSE                                         !Is this is a new subset?
  784.      %KeyAuto:AutoInc# = 1                       #<!then start numbering at 1
  785.     END                                          !End test subset match
  786.    #ELSE                                         #!No subset support
  787.      %KeyAuto:AutoInc# = %KeyAuto + 1            #<!Save incremented value
  788.    #ENDIF
  789.    END                                           #<!End IF errorcode
  790.  #ENDIF                                          #!End IF keyauto
  791. #ENDFOR                                          #!End FOR KEY
  792.    #INSERT(%ClearValues)
  793.    #FOR(%Formula)
  794.     #IF(UPPER(%FormulaClass) = 'PRIMEKEY')
  795.    #INSERT(%GenerateFormula)                    #<!Allow for Subset numbering
  796.     #ENDIF
  797.    #ENDFOR
  798.    #FOR(%Key)
  799.     #IF(%KeyAuto <> %NULL)
  800.    %KeyAuto = %KeyAuto:AutoInc#                  #<!Move the incremented value
  801.     #ENDIF
  802.    #ENDFOR
  803.    ADD(%Primary)                                 #<!Add the record now
  804.    IF ERRORCODE()                                #<!Was there an error?
  805.      CASE ERRORCODE()                            #<!Process errors
  806.        OF DupKeyErr                              #<!Is it a duplicate key?
  807.         CYCLE                                    #<!then try again
  808.        ELSE                                      #<!Else
  809.          IF DiskError('Record could not be ADDed') #<!Check any other error
  810.           #IF(%SharedFiles = 'TRUE')
  811.           FREE(RecordQueue)                      #<!Free the memory Queue
  812.           #ENDIF
  813.           #IF(%PullDownStructure)
  814.           CLOSE(%PullDown)
  815.           #ENDIF
  816.           RETURN                                 #<!Return to caller
  817.        END                                       #<!End IF Diskerror
  818.      END                                         #<!End CASE errorcode
  819.    ELSE                                          #<!Else no error
  820.      BREAK                                       #<!so BREAK Loop
  821.    END                                           #<!End IF errorcode
  822.   END                                            #<!End LOOP for Autonumbering
  823.   AutoIncAdd = 1                                 #<!Switch AutoIncAdd ON
  824.   AutoAddPtr = POSITION(%Primary)                #<!Save the record position
  825.   RESET(%Primary,AutoAddPtr)                     #<!Position to record we added
  826.   HOLD(%Primary,4)                               #<!Hold the record
  827.   NEXT(%Primary)                                 #<!and read it in to buffer
  828.   IF DiskError('Could not READ Record')          #<!Check for I/O error
  829.     #IF(%SharedFiles = 'TRUE')
  830.     FREE(RecordQueue)                            #<!Free the memory Queue
  831.     #ENDIF
  832.     #IF(%PullDownStructure)
  833.     CLOSE(%PullDown)
  834.     #ENDIF
  835.     RETURN                                       #<!And return to caller
  836.   END                                            #<!End IF Diskerror
  837.   Action = ChangeRecord                          #<!Action is now change
  838.   EXIT                                           #<!Exit the routine
  839.   #ENDIF
  840. #!***************************************************************************
  841. #GROUP(%RestoreAuto)
  842.     #FOR(%Key)
  843.     #IF(%KeyAuto <> %NULL)
  844. %KeyAuto = %KeyAuto:AutoInc#                     #<!Restore incremented value
  845.     #ENDIF
  846.     #ENDFOR
  847. #!***************************************************************************
  848. #GROUP(%SetupConcurrency)
  849. DO InitializeQueue                               #<!Save record to QUEUE
  850. SavePointer = POSITION(%Primary)                 #<!Save the record position
  851. #!***************************************************************************
  852. #GROUP(%ConflictUpdate)
  853. PUT(RecordQueue)                                 #<!Update the memory Queue
  854. GLO:Message1 = 'The Record was changed by another station '
  855. GLO:Message2 = 'your screen now reflects the changed data '
  856. GLO:Message3 = 'OK button to continue, or CANCEL to abort '
  857. ShowWarning                                      #<!Notify the user of changes
  858. SELECT(1)                                        #<!Place cursor on 1st field
  859. DISPLAY                                          #<!Update the screen
  860. AbortWrite# = 1                                  #<!Turn AbortWrite# ON
  861. EXIT                                             #<!Exit the Routine
  862. #!***************************************************************************
  863. #GROUP(%FormEditRoutines)
  864.    #FOR(%ScreenField)
  865.     #IF(%ScreenFieldUse <> '?Ok')
  866.      #IF(%ScreenFieldUse <> '?Cancel')
  867.       #IF(%ScreenFieldUse <> '?Next_Page')
  868.        #IF(%ScreenFieldUse <> '?Previous_Page')
  869.         #IF(%ScreenFieldUse <> '?Base_Page')
  870.          #IF(%ScreenFieldUse <> '?Last_Page')
  871.          #SET(%RangeCodeOn,%NULL)
  872.          #SET(%FieldLookUpOn,%NULL)
  873.       #INSERT(%RangeLookupCheck)
  874.       #IF(%ScreenFieldEdit OR %RangeCodeOn OR %FieldLookUpOn)
  875.   OF %ScreenField                                #<!Screen field selected
  876.         #IF(%FieldLookupOn)
  877.     #INSERT(%FieldLookupCode)
  878.         #ENDIF
  879.         #IF(%RangeCodeOn)
  880.     #INSERT(%RangeCode)
  881.         #ENDIF
  882.         #IF(%ScreenFieldEdit)
  883.     %ScreenFieldEdit                             !Screen field edit proc
  884.         #ENDIF
  885.          #ENDIF
  886.         #ENDIF
  887.        #ENDIF
  888.       #ENDIF
  889.      #ENDIF
  890.      #ENDIF
  891.     #ENDIF
  892.    #ENDFOR
  893.   #FOR(%PulldownField)                          #! add all procedure or
  894.     #IF(%PulldownFieldType = 'PROCEDURE')       #! source code calls
  895. OF %PulldownField                              #<!For a Pulldown field
  896.   %PulldownFieldProc                           #<!  execute its procedure
  897.     #ENDIF
  898.   #ENDFOR
  899. #!***************************************************************************
  900. #GROUP(%RangeLookupCheck)
  901.     #IF(%ScreenFieldType = 'ENTRY')
  902.       #FIX(%Field,%ScreenFieldUse)
  903.         #IF(%Field = %ScreenFieldUse)
  904.           #IF(%FieldRangeLow <> %NULL OR %FieldRangeHigh <> %NULL)
  905.             #SET(%RangeCodeOn,'TRUE')
  906.           #ELSE
  907.             #SET(%RangeCodeOn,%NULL)
  908.           #ENDIF
  909.           #IF(%FieldLookup)
  910.             #SET(%FieldLookupOn,'TRUE')
  911.           #ELSE
  912.             #SET(%FieldLookupOn,%NULL)
  913.           #ENDIF
  914.         #ENDIF
  915.     #ENDIF
  916. #!***************************************************************************
  917. #GROUP(%RangeCode)
  918. #IF(%ScreenFieldType = 'ENTRY')
  919.   #FIX(%Field,%ScreenFieldUse)
  920.     #IF(%Field = %ScreenFieldUse)
  921.       #IF(%FieldRangeLow <> %NULL OR %FieldRangeHigh <> %NULL)
  922.         #IF(%FieldRangeLow = %NULL)
  923. IF KEYCODE() <> EscKey
  924.   IF %ScreenFieldUse > %FieldRangeHigh
  925.   GLO:Message1 = 'The value entered in %FieldID'
  926.   GLO:Message2 = 'cannot exceed %FieldRangeHigh'
  927.         #ELSIF(%FieldRangeHigh = %NULL)
  928. IF KEYCODE() <> EscKey
  929.   IF %ScreenFieldUse < %FieldRangeLow
  930.   GLO:Message1 = 'The value entered in %FieldID'
  931.   GLO:Message2 = 'cannot be less than %FieldRangeHigh'
  932.         #ELSE
  933. IF KEYCODE() <> EscKey
  934.   IF ~INRANGE(%ScreenFieldUse,%FieldRangeLow,%FieldRangeHigh)
  935.     GLO:Message1 = 'Valid entries for %FieldID'
  936.     GLO:Message2 = 'are from %FieldRangeLow TO  %FieldRangeHigh'
  937.         #ENDIF
  938.     ShowWarning
  939.     SELECT(%ScreenField)
  940.     CYCLE
  941.   END
  942. END                                              !Not EscKey
  943.       #ENDIF
  944.     #ENDIF
  945. #ENDIF
  946. #!***************************************************************************
  947. #GROUP(%FieldLookupCode)
  948.     #IF(%ScreenFieldType = 'ENTRY')
  949.       #FIX(%Field,%ScreenFieldUse)
  950.       #IF(%Field = %ScreenFieldUse)
  951.         #IF(%FieldLookup)
  952.           #FIX(%File,%FieldFile)
  953.           #FIX(%Relation,%FieldLookup)
  954.          #IF(%RelationType = 'MANY:1')
  955. IF KEYCODE() <> EscKey
  956.         #FOR(%RelationKeyField)
  957.   %RelationKeyField = %RelationKeyFieldLink      #<!Assign linking field value
  958.         #ENDFOR
  959.   GET(%Relation,%RelationKey)                    #<!Lookup record
  960.   IF ERRORCODE()                                 #<!Did the GET succeed ?
  961.   #FIX(%File,%FieldLookup)
  962.     CLEAR(%FilePre:Record)                       #<!Clear record if unsuccessful
  963.     GLO:Message1 = 'Error: ' & ERRORCODE() & ' '& ERROR() #<!Build error message
  964.     GLO:Message2 = 'The value you enter must exist in the'
  965.     GLO:Message3 = 'File: %FieldLookup'          #<!Identify the Lookup file
  966.     ShowWarning                                  #<!Notify the user
  967.     SELECT(%ScreenField)                         #<!Reselect the screen field
  968.   END                                            #<!End IF Errorcode
  969. END                                              #<!Not EscKey
  970.          #ENDIF
  971.         #ENDIF
  972.       #ENDIF
  973.     #ENDIF
  974. #!***************************************************************************
  975. #GROUP(%FieldLookupOpen)
  976.   #FOR(%ScreenField)
  977.     #IF(%ScreenFieldType = 'ENTRY')
  978.      #FIX(%Field,%ScreenFieldUse)
  979.         #IF(%Field = %ScreenFieldUse)
  980.           #IF(%FieldLookup)
  981.            #FIX(%File,%FieldFile)
  982.            #FIX(%Relation,%FieldLookup)
  983.             #IF(%RelationType = 'MANY:1')
  984.              #FIX(%Secondary,%Relation)
  985.              #IF(%Secondary = %NULL)
  986.               #IF(%CloseFiles)                  #!Generate function for close
  987. %Relation::Opened = CheckOpen(%Relation)       #<!Ensure %Relation file is open
  988.               #ELSE
  989. CheckOpen(%Relation)                           #<!Ensure %Relation file is open
  990.               #ENDIF
  991. #SET(%ErrorMessage,%NULL)
  992. #ERROR(%ErrorMessage)
  993. #SET(%ErrorMessage,( 'WARNING the File: '& UPPER(%Relation) & ' used in Procedure: '& %Procedure ))
  994. #ERROR(%ErrorMessage)
  995. #SET(%ErrorMessage,( 'does not exist in the Procedure File Schematic'))
  996. #ERROR(%ErrorMessage)
  997. #SET(%ErrorMessage, %NULL)
  998. #ERROR(%ErrorMessage)
  999.              #ENDIF
  1000.             #ENDIF
  1001.           #ENDIF
  1002.         #ENDIF
  1003.     #ENDIF
  1004.   #ENDFOR
  1005. #!***************************************************************************
  1006. #GROUP(%DupKeyCode)
  1007. #FIX(%File,%Primary)
  1008. IF ERRORCODE() = DupKeyErr                       #<! Duplicate key detected
  1009.   #FOR(%Key)
  1010.   #IF(UPPER(%KeyDuplicate) <> 'Y')
  1011.   IF DUPLICATE(%Key)                             #<!check unique keys
  1012.     GLO:Message3 = '[ '
  1013.     #FOR(%KeyField)
  1014.     GLO:Message3 = Clip(GLO:Message3) & (' %KeyField ')
  1015.     #ENDFOR
  1016.     GLO:Message3 = Clip(GLO:Message3)&' ]'
  1017.     GLO:Message1 = 'This record creates a duplicate key entry'
  1018.     GLO:Message2 = 'The unique key field(s) are listed below: '
  1019.     ShowWarning                                  #<!inform the user
  1020.   END
  1021.   #ENDIF
  1022.   #ENDFOR
  1023.   SELECT(1)                                      #<!select first field
  1024.   DISPLAY                                        #<!re-display the screen
  1025.   CYCLE                                          #<!back to main loop
  1026. END                                              #<!End IF Duplicate errorcode
  1027. #!***************************************************************************
  1028. #GROUP(%PositionCheck)
  1029. IF POSITION(%Primary) <> SavePointer             #<!compare the positions
  1030.   GLO:Message1 = 'The Record was Deleted by another workstation'
  1031.   GLO:Message2 = 'when you return to the entry FORM choose OK  '
  1032.   GLO:Message3 = 'to ADD as a new record, or CANCEL to abort   '
  1033.   ShowWarning
  1034.   #INSERT(%InsertMessage)
  1035.   Action = AddRecord
  1036.   GET(RecordQueue,2)                             #<!Get the users changes
  1037.   %FilePre:Record = Sav:SaveRecord               #<!Update the Record buffer
  1038.   #IF(%MemoChk = 'TRUE')
  1039.   #FOR(%Field)
  1040.   #IF(%FieldType = 'MEMO')
  1041.   %Field = SAV:%FieldID                          #<!Update the Memo buffer
  1042.   #ENDIF
  1043.   #ENDFOR
  1044.   #ENDIF
  1045.   DISPLAY                                        #<!Update the screen
  1046.   SELECT(1)                                      #<!Place the cursor on 1st field
  1047.   RELEASE(%Primary)                              #<!Release HOLD request
  1048.   CYCLE                                          #<!Re-start the Loop
  1049. END                                              #<!End Position check
  1050. #!***************************************************************************
  1051. #GROUP(%ClearValues)
  1052. CLEAR(%FilePre:Record)                           #<!CLEAR Record buffer
  1053. #FOR(%FileMemo)
  1054. CLEAR(%FileMemo)                                 #<!CLEAR Memo buffer
  1055. #ENDFOR
  1056. #!***************************************************************************
  1057. #GROUP(%InitFormSymbols)
  1058. #FIX(%File,%Primary)
  1059. #SET(%PrimaryDriver,%FileType)
  1060. #FOR(%HotKey)
  1061.  #IF(%HotKeyProc)
  1062.   #SET(%HotKeysExist,'TRUE')
  1063.   #BREAK
  1064.  #ENDIF
  1065. #ENDFOR
  1066. #FOR(%Key)
  1067.   #IF(%KeyAuto <> %NULL)
  1068.     #SET(%AutoInc,'TRUE')
  1069.   #ENDIF
  1070.   #IF(%KeyDuplicate <> 'Y')
  1071.     #SET(%DupKeyCheck,'TRUE')
  1072.   #ENDIF
  1073. #ENDFOR
  1074. #FOR(%Formula)
  1075.   #IF(UPPER(%FormulaClass) = '')
  1076.     #SET(%LoopFormulasExist,'TRUE')
  1077.   #ENDIF
  1078.   #IF(UPPER(%FormulaClass) = 'PRIMEKEY')
  1079.     #SET(%PrimeKeysExist,'TRUE')
  1080.   #ENDIF
  1081. #ENDFOR
  1082. #FOR(%Filememo)
  1083.   #SET(%MemoChk,'TRUE')
  1084.   #BREAK
  1085. #ENDFOR
  1086. #FOR(%Field)
  1087.   #IF(%FieldInitial <> %NULL)
  1088.     #SET(%InitRoutine,'TRUE')
  1089.     #BREAK
  1090.   #ENDIF
  1091. #ENDFOR
  1092. #FOR(%Relation)
  1093.  #IF(%RelationType = '1:MANY')
  1094.    #SET(%Instance,%Relation)
  1095.    #SET(%LevelOne,(%LevelOne & ','& %Instance))
  1096.    #FOR(%RelationKeyField)
  1097.      #IF(%RelationKeyFieldLink)
  1098.        #SET(%Link,%RelationKeyField)
  1099.        #SET(%RKFL,%RelationKeyFieldLink)
  1100.         #SET(%LevelOneLinks,(%LevelOneLinks & ','& %Link))
  1101.         #SET(%LinkPool,(%LinkPool & ','& %RKFL))
  1102.      #ENDIF
  1103.    #ENDFOR
  1104.   #IF(%RelationConstraintUpdate OR %RelationConstraintDelete)
  1105.     #SET(%RelatedFiles,'TRUE')
  1106.     #INSERT(%PrimaryDriverChk)
  1107.   #ENDIF
  1108.   #IF(%RelationConstraintDelete = 'RESTRICT')
  1109.     #SET(%RestrictDelete,'TRUE')
  1110.   #ENDIF
  1111.   #IF(%RelationConstraintUpdate = 'RESTRICT')
  1112.     #SET(%RestrictUpdate,'TRUE')
  1113.   #ENDIF
  1114.   #IF(%RelationConstraintDelete = 'CASCADE')
  1115.     #SET(%CascadeDelete,'TRUE')
  1116.   #ENDIF
  1117.   #IF(%RelationConstraintUpdate = 'CASCADE')
  1118.     #SET(%CascadeUpdate,'TRUE')
  1119.   #ENDIF
  1120.   #IF(%RelationConstraintDelete = 'CLEAR')
  1121.     #SET(%ClearOnDelete,'TRUE')
  1122.   #ENDIF
  1123.   #IF(%RelationConstraintUpdate = 'CLEAR')
  1124.     #SET(%ClearOnUpdate,'TRUE')
  1125.   #ENDIF
  1126.  #ENDIF
  1127. #ENDFOR
  1128. #FOR(%Secondary)
  1129. #IF(%SecondaryType = 'MANY:1')
  1130.   #SET(%SecondaryExist,'TRUE')
  1131. #ENDIF
  1132. #ENDFOR
  1133. #SET(%SetFile,%Primary)
  1134. #INSERT(%SpatialRelate)
  1135. #!***************************************************************************
  1136. #GROUP(%DeclareRelatedData)
  1137. #FIX(%File,%Primary)
  1138. #FOR(%Relation)
  1139.  #FOR(%RelationKeyField)
  1140.    #IF(%RelationKeyFieldLink <> %NULL)
  1141. %Relation:Lnk:%RelationKeyFieldLink LIKE(%RelationKeyFieldLink) !Relation Link field
  1142.    #ENDIF
  1143.  #ENDFOR
  1144. #ENDFOR
  1145. #!***************************************************************************
  1146. #GROUP(%RelationalAccessFlds)
  1147. #FIX(%File,%SetFile)
  1148. #FOR(%Relation)
  1149.  #IF(%RelationType = '1:MANY')
  1150.   #FOR(%RelationKeyField)
  1151.    #IF(%RelationKeyFieldLink <> %NULL)
  1152.     #SET(%Constructor,(%Relation & ':Lnk:' & %RelationKeyFieldLink))
  1153.      #IF(INSTRING(%Constructor,%Array,1,1) = '0')
  1154. %Relation:Lnk:%RelationKeyFieldLink LIKE(%RelationKeyFieldLink) #<!Define a link field
  1155.     #SET(%Element,(',' & %Constructor))
  1156.     #SET(%Array,(%Array & %Element))
  1157.      #ENDIF
  1158.    #ENDIF
  1159.   #ENDFOR
  1160.    #SET(%SetFile,%Relation)
  1161. #INSERT(%RelationalAccessFlds)
  1162.  #ENDIF
  1163. #ENDFOR
  1164. #!**************************************************************************
  1165. #GROUP(%GenFormulas)
  1166. #IF(%GenerateFormulasOn)
  1167.  
  1168. FormulaFields ROUTINE
  1169.  #FOR(%Formula)
  1170.   #IF(UPPER(%FormulaClass) <> 'PRIMEKEY')
  1171.   #IF(UPPER(%FormulaClass) <> 'SETUP')
  1172.   #IF(UPPER(%FormulaClass) <> 'RETURN')
  1173.    #IF(%CodePosition = %NULL OR %CodePosition = %FormulaClass)
  1174.      #IF(%FormulaType = 'COMPUTED')
  1175.   %Formula = %FormulaComputation                 #<!Computed Formula (no class)
  1176.      #ELSE
  1177.   IF %FormulaCondition                           #<!If Formula condition
  1178.     %Formula = %FormulaTrue                      #<! is TRUE
  1179.        #IF(%FormulaFalse)
  1180.   ELSE                                           ! else
  1181.     %Formula = %FormulaFalse                     #<! condition is FALSE
  1182.        #ENDIF
  1183.   END                                            #<!End formula condition
  1184.        #ENDIF
  1185.        #SET(%CurrentFormula,('?' & %Formula))
  1186.        #FIX(%Screenfield,%CurrentFormula)
  1187.        #IF(%Screenfield)
  1188.   DISPLAY(?%Formula)                             #<!Update screen display
  1189.        #ENDIF
  1190.    #ENDIF
  1191.  
  1192.   #ENDIF                                         #!Not PrimeKey class
  1193.   #ENDIF                                         #!Not Setup class
  1194.   #ENDIF                                         #!Not Return class
  1195.  
  1196.  #ENDFOR
  1197. #ENDIF
  1198. #!***************************************************************************
  1199. #GROUP(%SpatialRelate)
  1200. #FIX(%File,%SetFile)
  1201. #FOR(%Relation)
  1202.  #IF(%RelationType = '1:MANY')
  1203.   #INSERT(%DriverCheck)
  1204.   #IF(INSTRING(%SetFile,%LevelOne,1,1) = '0')
  1205.    #FOR(%RelationKeyField)
  1206.     #IF(%RelationKeyFieldLink)
  1207.      #SET(%RKFL,%RelationKeyFieldLink)
  1208.      #IF(INSTRING(%RKFL,%LinkPool,1,1) = '0')
  1209.       #SET(%LinkPool,(%LinkPool & ','& %RKFL))
  1210.      #ENDIF
  1211.     #ENDIF
  1212.    #ENDFOR
  1213.   #ENDIF
  1214. #SET(%SetFile,%Relation)
  1215. #INSERT(%SpatialRelate)
  1216. #ENDIF
  1217. #ENDFOR
  1218. #!**************************************************************************
  1219. #GROUP(%SecondaryChanged)
  1220. #FOR(%Secondary)                                #! for fields on the form
  1221.   #IF(%SecondaryType = 'MANY:1')                #!Check for lookup files
  1222.     #FIX(%File,%SecondaryTo)
  1223.     #FIX(%Relation,%Secondary)
  1224.      #FOR(%RelationKeyField)
  1225.        #IF(RelationKeyFieldLink)
  1226. IF %RelationKeyField <> %RelationKeyFieldLink    #<!Check for changes
  1227.   DO SecondaryLookups                            #<!Call lookup Routine
  1228. END
  1229.        #ENDIF
  1230.       #ENDFOR
  1231.   #ENDIF
  1232. #ENDFOR
  1233. #!***************************************************************************
  1234. #GROUP(%FieldDups)
  1235.  #FOR(%ScreenField)
  1236.  #IF(%ScreenFieldUse)
  1237.    #SET(%Fld,%ScreenFieldUse)
  1238.    #FIX(%Field,%ScreenFieldUse)
  1239.   #IF(SUB(%Fld,1,1) <> '?')
  1240.     #IF(%FieldID)
  1241.       #IF(%FieldFile = %Primary)
  1242.        #IF(%FieldDimension1)
  1243.         #SET(%DimField,%Field)
  1244.         #IF(INSTRING(%DimField,%DimPool,1,1) = '0')
  1245.          #SET(%DimPool,(%DimPool & ',' & %DimField))
  1246. Dup::%Field   LIKE(%Field)
  1247.         #ENDIF
  1248.        #ELSE
  1249. Dup::%ScreenFieldUse LIKE(%ScreenFieldUse)
  1250.        #ENDIF
  1251.       #ENDIF
  1252.     #ENDIF
  1253.   #ENDIF
  1254.  #ENDIF
  1255.  #ENDFOR
  1256. #!***************************************************************************
  1257. #GROUP(%SaveScrFlds)
  1258.  
  1259. SaveScrFlds ROUTINE
  1260.  #FOR(%ScreenField)
  1261.  #IF(%ScreenFieldUse)
  1262.   #SET(%Fld,%ScreenFieldUse)
  1263.    #FIX(%Field,%ScreenFieldUse)
  1264.   #IF(SUB(%Fld,1,1) <> '?')
  1265.     #IF(%FieldID)
  1266.       #IF(%FieldFile = %Primary)
  1267.   Dup::%ScreenFieldUse = %ScreenFieldUse         #<!Save screen entry
  1268.       #ENDIF
  1269.     #ENDIF
  1270.   #ENDIF
  1271.  #ENDIF
  1272.  #ENDFOR
  1273. #!***************************************************************************
  1274. #GROUP(%DupFldCall)
  1275. IF KEYCODE() = %CopyKey                          #<!User requested field copy
  1276.   DO DupField                                    #<!Call duplication Routine
  1277. END                                              #<!End copy key check
  1278. #!***************************************************************************
  1279. #GROUP(%DupField)
  1280.  
  1281. DupField ROUTINE
  1282.   CASE SELECTED()                                !Which field is selected?
  1283.  #FOR(%ScreenField)
  1284.  #IF(%ScreenFieldUse)
  1285.   #SET(%Fld,%ScreenFieldUse)
  1286.    #FIX(%Field,%ScreenFieldUse)
  1287.   #IF(SUB(%Fld,1,1) <> '?')
  1288.     #IF(%FieldID)
  1289.       #IF(%FieldFile = %Primary)
  1290.     OF ?%ScreenFieldUse
  1291.       %ScreenFieldUse = Dup::%ScreenFieldUse     #<!Move saved entry to screen
  1292.       #ENDIF
  1293.     #ENDIF
  1294.   #ENDIF
  1295.  #ENDIF
  1296.  #ENDFOR
  1297.   END                                            #<!End Case Selected
  1298.   DISPLAY                                        #<!Update screen display
  1299. #!***************************************************************************
  1300. #GROUP(%CommitCheck)
  1301. #IF(%NoLogoutSupport = %NULL)
  1302. IF ~ERRORCODE()
  1303.   COMMIT                                         #<!Commit the transaction
  1304. ELSE                                             !If there was an error
  1305.   GLO:Message1 = 'Unable to complete the transaction'
  1306.   GLO:Message2 = 'Error: ' & ERRORCODE() & ' ' & ERROR()
  1307.   GLO:Message3 = 'Files will be restored to their original values'
  1308.   ROLLBACK                                       #<!Rollback the transaction
  1309.   ShowWarning                                    #<!Notify the user
  1310. END                                              !End error check
  1311. #ELSE
  1312. IF ERRORCODE()                                   !Check for error
  1313.     GLO:Message1 = 'The Referential Update/Delete encountered an error'
  1314.     GLO:Message2 = 'Error: '& ERRORCODE() & ' ' & ERROR()
  1315.     GLO:Message3 = 'Relational integrity for: ' & ERRORFILE() & 'is suspect'
  1316.   ShowWarning                                    #<!Notify the user
  1317. END                                              !End error check
  1318. #ENDIF
  1319. #!***************************************************************************
  1320. #GROUP(%AltKeys)
  1321. #IF(%Page2Proc)
  1322. OF Alt2                                          !Hotkey to Page 2
  1323.   PRESS(AltN)                                    !Press Next_Page Key
  1324. #ENDIF
  1325. #IF(%Page3Proc)
  1326. OF Alt3                                          !Hotkey to Page 3
  1327.   LOC:Page = 2                                   !Press Next_Page Key
  1328.   PRESS(AltN)
  1329. #ENDIF
  1330. #IF(%Page4Proc)
  1331. OF Alt4                                          !Hotkey to Page 4
  1332.   LOC:Page = 3                                   !Press Next_Page Key
  1333.   PRESS(AltN)
  1334. #ENDIF
  1335. #IF(%Page5Proc)
  1336. OF Alt5                                          !Hotkey to Page 5
  1337.   LOC:Page = 4                                   !Press Next_Page Key
  1338.   PRESS(AltN)
  1339. #ENDIF
  1340. #IF(%Page6Proc)
  1341. OF Alt6                                          !Hotkey to Page 6
  1342.   LOC:Page = 5                                   !Press Next_Page Key
  1343.   PRESS(AltN)
  1344. #ENDIF
  1345. #IF(%Page7Proc)
  1346. OF Alt7
  1347.   LOC:Page = 6                                   !Hotkey to Page 7
  1348.   PRESS(AltN)                                    !Press Next_Page Key
  1349. #ENDIF
  1350. #IF(%Page8Proc)
  1351. OF Alt8
  1352.   LOC:Page = 7                                   !Hotkey to Page 8
  1353.   PRESS(AltN)                                    !Press Next_Page Key
  1354. #ENDIF
  1355. #IF(%Page9Proc)
  1356. OF Alt9
  1357.   LOC:Page = 8                                   !Hotkey to Page 9
  1358.   PRESS(AltN)                                    !Press Next_Page Key
  1359. #ENDIF
  1360. #!***************************************************************************
  1361. #GROUP(%ProcCounter)
  1362.       #IF(%Page2Proc)
  1363.         #SET(%ProcCount,'2')
  1364.         #IF(%Page3Proc)
  1365.             #SET(%ProcCount,(%ProcCount + 1))
  1366.          #ENDIF
  1367.          #IF(%Page4Proc)
  1368.             #SET(%ProcCount,(%ProcCount + 1))
  1369.          #ENDIF
  1370.          #IF(%Page5Proc)
  1371.             #SET(%ProcCount,(%ProcCount + 1))
  1372.          #ENDIF
  1373.          #IF(%Page6Proc)
  1374.             #SET(%ProcCount,(%ProcCount + 1))
  1375.          #ENDIF
  1376.          #IF(%Page7Proc)
  1377.             #SET(%ProcCount,(%ProcCount + 1))
  1378.          #ENDIF
  1379.          #IF(%Page8Proc)
  1380.             #SET(%ProcCount,(%ProcCount + 1))
  1381.          #ENDIF
  1382.          #IF(%Page9Proc)
  1383.             #SET(%ProcCount,(%ProcCount + 1))
  1384.          #ENDIF
  1385.       #ENDIF
  1386. #!***************************************************************************
  1387. #GROUP(%ButtonCheck)
  1388.    #FOR(%ScreenField)
  1389.      #IF(UPPER(%ScreenFieldUse) = '?BASE_PAGE')
  1390.       #SET(%BasePageExists,'TRUE')
  1391.      #ENDIF
  1392.      #IF(UPPER(%ScreenFieldUse) = '?LAST_PAGE')
  1393.       #SET(%LastPageExists,'TRUE')
  1394.      #ENDIF
  1395.    #ENDFOR
  1396. #!***************************************************************************
  1397. #GROUP(%SavePrimedFields)
  1398. #FOR(%Key)
  1399.  #IF(%KeyAuto)
  1400.   #FOR(%KeyField)
  1401.    #IF(%KeyField <> %KeyAuto)
  1402. Prime::%KeyField  LIKE(%KeyField)
  1403.    #ENDIF
  1404.   #ENDFOR
  1405.  #ENDIF
  1406. #ENDFOR
  1407. #!***************************************************************************
  1408. #GROUP(%DriverCheck)
  1409. #IF(%FileType <> %PrimaryDriver)
  1410.   #SET(%ErrorMessage,%NULL)
  1411.   #ERROR(%ErrorMessage)
  1412.   #SET(%ErrorMessage,(' WARNING during Source Code Generation in Procedure: '& %Procedure ))
  1413.   #ERROR(%ErrorMessage)
  1414.   #SET(%ErrorMessage, ' the FILE Relationship uses multiple file drivers')
  1415.   #ERROR(%ErrorMessage)
  1416.   #SET(%ErrorMessage,(' see FORM Template Help, TOPIC: No Transaction Framing'))
  1417.   #ERROR(%ErrorMessage)
  1418.   #SET(%ErrorMessage, %NULL)
  1419.   #ERROR(%ErrorMessage)
  1420.   #SET(%NoLogoutSupport,'TRUE')
  1421. #ENDIF
  1422. #!***************************************************************************
  1423. #GROUP(%PrimaryDriverChk)
  1424. #IF((UPPER(%PrimaryDriver) <> 'BTRIEVE') AND (UPPER(%PrimaryDriver) <> 'CLARION'))
  1425.   #SET(%ErrorMessage,%NULL)
  1426.   #ERROR(%ErrorMessage)
  1427.   #SET(%ErrorMessage,(' WARNING during Code Generation in Procedure: '& %Procedure ))
  1428.   #ERROR(%ErrorMessage)
  1429.   #SET(%ErrorMessage,( ' PRIMARY file driver (' & %PrimaryDriver & ') does not support LOGOUT() '))
  1430.   #ERROR(%ErrorMessage)
  1431.   #SET(%ErrorMessage,('   see FORM Template Help, Topic: No Transaction Framing'))
  1432.   #ERROR(%ErrorMessage)
  1433.   #SET(%NoLogoutSupport,'TRUE')
  1434. #ENDIF
  1435. #!***************************************************************************
  1436. #GROUP(%CloseRelatedFiles)
  1437. #IF(%CloseFiles)                                #!Generate function for close
  1438. #FIX(%File,%SetFile)
  1439. #FOR(%Relation)
  1440.     #IF(%RelationType = '1:MANY')
  1441.        #SET(%FileToClose,%Relation)
  1442.        #IF(INSTRING(%FileToClose,%ClosedFilesList,1,1) = '0')
  1443. IF %Relation::Opened THEN CLOSE(%Relation).      #<!Close files opened by proc
  1444.        #SET(%ClosedFilesList,(%ClosedFilesList & %FileToClose))
  1445.        #ENDIF
  1446.       #SET(%SetFile,%Relation)
  1447. #INSERT(%CloseRelatedFiles)
  1448.     #ENDIF
  1449. #ENDFOR
  1450. #ENDIF
  1451. #!***************************************************************************
  1452. #GROUP(%CloseRelatedFlags)
  1453. #IF(%CloseFiles)                                 #!Generate function for close
  1454. #FIX(%File,%SetFile)
  1455. #FOR(%Relation)
  1456.     #IF(%RelationType = '1:MANY')
  1457.        #SET(%FlagToClose,%Relation)
  1458.        #IF(INSTRING(%FlagToClose,%ClosedFlagsList,1,1) = '0')
  1459. %Relation::Opened BYTE                           #<!Close flag for related files
  1460.        #SET(%ClosedFlagsList,(%ClosedFlagsList & %FlagToClose))
  1461.        #ENDIF
  1462.      #SET(%SetFile,%Relation)
  1463. #INSERT(%CloseRelatedFlags)
  1464.     #ENDIF
  1465. #ENDFOR
  1466. #ENDIF
  1467. #!***************************************************************************
  1468. #CHAIN('CLARION6.TPX')
  1469.