home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / clarion / ppstpx.zip / OM6.TPX < prev    next >
Text File  |  1993-06-08  |  26KB  |  558 lines

  1. #!-------------------------------------------------------------------------------#!
  2. #!      OM6.TPX
  3. #!
  4. #!      Child     Update a batch of child records.
  5. #!
  6. #!------------------------------------------------------------------------------
  7. #!
  8. #!                           The Child Template
  9. #!
  10. #!   The Child template scrolls child records from a file on the screen
  11. #!   and allows updating the records on the same screen.  A parent
  12. #!   file must be identified and a valid parent record must be in memory
  13. #!   when this procedure is called.
  14. #!
  15. #!   The QUEUE will contain all children records for a particular
  16. #!   Parent record.  Changes to the children records are made to the
  17. #!   QUEUE and are only written to disk upon completion of the OK
  18. #!   button.  The update process is framed within a logged transaction.
  19. #!   The child file must use a file driver which supports transaction
  20. #!   processing in order to use this template.
  21. #!
  22. #!   The Child template's screen will contain a scrolling listbox
  23. #!   With Add, Change, Delete, Ok and Cancel pushbuttons and a fixed
  24. #!   field entry area with Save and Exit Buttons.
  25. #!
  26. #!   The Child template does not support autonumbering of keys.
  27. #!
  28. #!------------------------------------------------------------------------------
  29. #PROCEDURE(Child,'Update child records from a parent'),SCREEN,PULLDOWN
  30. #!
  31. #DISPLAY('')
  32. #PROMPT('First Upd&ate Field',FIELD),%FirstUpdateField
  33. #PROMPT('Parent F&ile',FILE),%ParentFile
  34. #PROMPT('Exit on &Null Parent',CHECK),%NullParentExit
  35. #PROMPT('Upd&ate Parent on OK',CHECK),%PutParent
  36. #INSERT(%SetChildSymbols)
  37. #PROTOTYPE('')
  38.  
  39. %Procedure       PROCEDURE
  40.  
  41. #FIX(%File,%Primary)
  42. RecordQueue      QUEUE,PRE(SAV)
  43. Line              STRING(%ScreenFieldQueueSize) #<! Line to be scrolled
  44. SaveRecord        LIKE(%FilePre:Record),PRE(SAV)
  45. SkipRecord        BYTE
  46. #FIX(%Key,%PrimaryKey)
  47. #SET(%FirstField, %Null)
  48. #SET(%SortString,%Null)
  49. #FOR(%KeyField)
  50.   #FIX(%Field,%KeyField)
  51.   #IF(%FirstField = %Null)
  52.     #SET(%FirstField, %KeyField)
  53.     #SET(%FirstFieldSequence, %KeyFieldSequence)
  54.   #ENDIF
  55.   #IF(%KeyFieldSequence <> 'DESCENDING')
  56.     #SET(%SortString, (CLIP(LEFT(%SortString)) & ',+SAV:' & %FieldID))
  57.   #ELSE
  58.     #SET(%SortString, (CLIP(LEFT(%SortString)) & ',-SAV:' & %FieldID))
  59.   #ENDIF
  60. #ENDFOR
  61. SAV:RecordPosition STRING(256)
  62. #SET(%MemoField,%Null)
  63. #FOR(%Field)
  64.   #IF(%FieldType = 'MEMO')
  65.   #SET(%MemoField,%FieldID)
  66. SAV:%FieldID     STRING(SIZE(%Field))
  67.   #ENDIF
  68. #ENDFOR
  69.                  .                             #<!End Queue structure
  70.  
  71. FirstPage        BYTE(1)                         ! Page display variable
  72. EntryMode        BYTE                            ! Toggles for entry mode
  73. ScrollMode       EQUATE(0)                       !   ScrollMode or
  74. UpdateMode       EQUATE(1)                       !   UpdateMode
  75. DRecs            SHORT                           ! Number of Child records
  76. QRecs            SHORT                           ! Number of QUEUE records
  77. I                BYTE                            ! QUEUE record pointer
  78. ChildAction           BYTE(0)                         ! Update mode
  79. NoMoreFields     BYTE(0)                         ! No more fields
  80. TransactionError BYTE(0)                         ! Transaction Error
  81. RecordEntryOne   BYTE(0)                         ! Starting record in QUEUE
  82.  
  83. #INSERT(%LocalPPSVariables)                    #<! Declare Variables PPS
  84.  
  85. %LocalData
  86. %ScreenStructure
  87. %PulldownStructure
  88. #EMBED('Data Section')
  89.  
  90.   CODE
  91.   ProcedureName = '%Procedure'                 #<!Fill ProcedureName var. PPS
  92.   #EMBED('Setup Procedure')
  93.   #INSERT(%NullParentCheck)                     #!Return if blank parent
  94.   #INSERT(%FileMgrStart)                       #<!Insert File Manager. PPS
  95.   #INSERT(%OpenSecondaryFiles)                  #!Open any secondary files
  96.   #INSERT(%HoldParentRecord)                    #!Hold the parent record
  97.   OPEN(SCREEN)                                   !Open the screen
  98.   #EMBED('Setup Screen')
  99.   #IF(%Pulldown)                                #!If a Pulldown exists
  100.   OPEN(%Pulldown)                              #<!Open the Pulldown
  101.   #ENDIF
  102.   DO EnterScrollMode                             !Select Scrolling mode
  103.   DO FillQueues                                  !Fill the Queues
  104.   DRecs = RECORDS(RecordQueue)                   !Save the number of children
  105.   #FIX(%File,%Primary)
  106.   DISPLAY                                        !Show the listbox
  107.   LOOP
  108.     #INSERT(%GenerateFormulas)                  #!Generate all formulas
  109.     #EMBED('Top of Accept Loop')
  110.     CASE SELECTED()                              !Jump to setup routine
  111.       OF NoMoreFields
  112.         SELECT(?Save)
  113.         DO EnterScrollMode                       ! Switch modes
  114.       #INSERT(%ScreenSetupRoutines)
  115.     END                                          !End CASE
  116.     ACCEPT                                       !Accept user input
  117.  
  118.     CASE KEYCODE()
  119.     #FOR(%HotKey)
  120.     OF %HotKey                                 #<!User defined HotKey
  121.       %HotKeyProc                              #<!HotKey Procedure
  122.     #ENDFOR
  123.     #INSERT(%FileMgrView)                      #!Insert File Manager View PPS
  124.     END
  125.  
  126.     IF EntryMode = ScrollMode                    !If processing the ScrollMode
  127.       CASE FIELD()                               ! Jump to edit routine
  128.       OF ?List                                   ! Process the List box
  129.         GET(RecordQueue,CHOICE())              #<! Get the Record Data
  130.     #FIX(%File,%Primary)
  131.         %FilePre:Record = SAV:SaveRecord       #<! Fill the fields
  132.         #INSERT(%GetChildSecondary)
  133.         DISPLAY                                  ! and re-display
  134.         IF KEYCODE() = MouseLeft2                ! On Mouse double click
  135.           PRESS(EnterKey)                        !  Press the EnterKey
  136.         END                                      ! End IF
  137.       OF ?Insert                                 ! Process the Insert Button
  138.         #FIX(%File,%Primary)
  139.         ChildAction = AddRecord                  !  Set to adding a record
  140.         CLEAR(%FilePre:RECORD)                 #<!  Clear the record for entry
  141.         #INSERT(%GetChildSecondary)
  142.         DO EnterUpdateMode                       ! Switch to update mode
  143.         #IF(%InitRoutine)                        #<!Field(s) initial value
  144.         DO InitializeFields                      !Initial values from dictionary
  145.         #ENDIF
  146.       OF ?Change                                 ! Process the Change Button
  147.         ChildAction = ChangeRecord               !  Set to Changing a record
  148.         DO EnterUpdateMode                       !  Switch modes
  149.       OF ?Delete                                 ! Process the Delete Button
  150.         ChildAction = DeleteRecord               !  Set to Deleting a record
  151.         DELETE(RecordQueue)                      !  Delete Record Queue Entry
  152.         DISPLAY                                  !  Redisplay the list box
  153.         SELECT(?List)                            !  Select the list box
  154.         ChildAction = 0                          !  Reset the Action
  155.         CYCLE                                    !  Cycle to accept input
  156.       OF ?Ok                                     ! Process the Ok Button
  157.         QRecs = RECORDS(RecordQueue)             !
  158.   #FIX(%File, %Primary)
  159.         CLEAR(%FilePre:RECORD)                 #<!Clear the record buffer
  160.         TransactionError = 0                     !Clear Transaction error
  161.   #FIX(%File, %ParentFile)
  162.   #FIX(%Relation,%Primary)
  163.   #IF(%RelationType = '1:MANY')
  164.     #FOR(%RelationKeyField)
  165.       #IF(%RelationKeyFieldLink)
  166.         %RelationKeyField = %RelationKeyFieldLink #<!Assign linking field value
  167.       #ENDIF
  168.     #ENDFOR
  169.   #ENDIF
  170.         SET(%RelationKey,%RelationKey)         #<!Set to the matching record
  171.         LOGOUT(2,%Primary)                     #<!Enable transaction logging
  172.         IF ERRORCODE() = BadTranErr              !If transaction error occurs
  173.           GLO:Message1 = 'Unable to save your changes at this time.'
  174.           GLO:Message2 = 'Another user may be saving a transaction.'
  175.           GLO:Message3 = 'Try again.'
  176.           ShowWarning                            ! Show the transaction error
  177.           SELECT(?Ok)                            ! Reselect the Ok button
  178.           CYCLE                                  ! Cycle to ACCEPT input
  179.         END                                      !End IF
  180.         #INSERT(%UpdateChildRecords)
  181.         IF TransactionError                      !If transaction error occurs
  182.           GLO:Message1 = 'Unable to save your changes at this time.'
  183.           GLO:Message2 = 'Error: '& ERROR()
  184.           GLO:Message3 = 'Make any necessary changes and try again.'
  185.           ShowWarning                            ! Show the transaction error
  186.           ROLLBACK                               ! Rollback the changes.
  187.           SELECT(?List,I)                        ! Reselect the List box
  188.           PRESS(EnterKey)                        ! Setup to change record
  189.           CYCLE                                  ! Cycle to ACCEPT input
  190.         ELSE                                     !Else
  191.           COMMIT                                 ! Commit the changes to disk
  192.         END                                      !End IF
  193.         #INSERT(%PutParentFile)
  194.         BREAK                                    ! Break to Return to Caller
  195.       OF ?Cancel                                 !Process the Cancel Button
  196.         BREAK                                    ! Break to Return to Caller
  197.       END                                        !End CASE
  198.     ELSE                                         ! Else if update mode
  199.       #INSERT(%GetChildSecondary)
  200.       DISPLAY                                    ! Display the new record
  201.       CASE FIELD()                               !
  202.       #INSERT(%ChildEditRoutines)
  203.       OF ?Save                                   ! Process the Save Button
  204.         CASE ChildAction                         ! Adding or Changing?
  205.         OF AddRecord                             ! When adding a new record.
  206.           #INSERT(%FillQueueFields)
  207.           ADD(RecordQueue %SortString)         #<! Add to the sorted queue
  208.           ChildAction = 0                        ! Reset the Action value
  209.         OF ChangeRecord                          ! When changing a record
  210.           #INSERT(%FillQueueFields)
  211.           PUT(RecordQueue %SortString)         #<! Add to the queue
  212.           ChildAction = 0                        ! Reset the Action value
  213.         END                                      ! Case
  214.         SELECT(1)                                !Start with the first field
  215.         SELECT                                   !and cycle non-stop
  216.         CYCLE                                    !restart main process loop
  217.       OF ?Exit                                   ! Process the Exit Button
  218.         DO EnterScrollMode                       ! Switch modes
  219.       END                                        !  End CASE
  220.     END                                          ! End IF
  221.     CASE FIELD()
  222.   #FOR(%PulldownField)
  223.     #IF(%PulldownFieldProc <> %NULL)
  224.     OF %PulldownField                          #<!For a selected menu item
  225.   %PulldownFieldProc                           #<!Call the procedure
  226.     #ENDIF
  227.   #ENDFOR
  228.     END                                          !End CASE for Pulldowns
  229.   END                                            !End LOOP
  230.   #EMBED('Prior to Return')
  231.   #IF(%Pulldown)                                #!If a Pulldown exists
  232.   CLOSE(%Pulldown)                             #<!Open the Pulldown
  233.   #ENDIF
  234.   #IF(%SharedFiles)
  235.   RELEASE(%ParentFile)                         #<!Release held parent record
  236.   #ENDIF
  237.   FREE(RecordQueue)                              !Free the QUEUE memory
  238.  
  239. #EMBED('End of Procedure')
  240. #INSERT(%FileMgrExit)                          #!Insert File Manager Exit PPS
  241.  
  242. #INSERT(%ChildInitFields)
  243.  
  244. EnterScrollMode ROUTINE                          !Switch screen mode routine
  245.   EntryMode = ScrollMode                         ! Switch to scroll mode
  246.   DISABLE(1,FIELDS())                            ! Disable listbox and buttons
  247.   ENABLE(?List)                                  ! Enable the list box
  248.   ENABLE(?Insert, ?Cancel)                       ! Enable the Buttons
  249.   SELECT(?List)
  250.   #EMBED('Enter Scroll Mode Routine')
  251.  
  252. EnterUpdateMode ROUTINE
  253.   EntryMode = UpdateMode                         !Switch screen mode routine
  254.   DISABLE(1,FIELDS())                            ! Disable listbox and buttons
  255.   ENABLE(?%FirstUpdateField, ?Exit)            #<! Enable the entry fields
  256.   Select(?%FirstUpdateField)                   #<! Select the first entry field
  257.   #EMBED('Enter Update Mode Routine')
  258.  
  259. FillQueues ROUTINE
  260.  
  261.   FREE(RecordQueue)                            #<!Clear the Record queue
  262.   #SET(%FixRows, '0')
  263.   #SET(%ListField,'?List')
  264.   #FIX(%ScreenField,%ListField)
  265.   #FOR(%ScreenFieldFix)
  266.     #SET(%FixRows, (%FixRows + 1))
  267.   SAV:Line = %ScreenFieldFix                   #<!Add list box fixed fields
  268.   ADD(RecordQueue %SortString)                 #<! Add to the sorted queue
  269.   DISPLAY(?List)                               #<!Blank the listbox
  270.   #ENDFOR
  271.   #FIX(%File, %Primary)
  272.   CLEAR(%FilePre:RECORD)                       #<!Clear the Child record
  273.   #FIX(%File, %ParentFile)
  274.   #FIX(%Relation,%Primary)
  275.   #IF(%RelationType = '1:MANY')
  276.     #FOR(%RelationKeyField)
  277.       #IF(%RelationKeyFieldLink)
  278.   %RelationKeyField = %RelationKeyFieldLink    #<!Assign linking field value
  279.       #ENDIF
  280.     #ENDFOR
  281.   #ENDIF
  282.   SET(%RelationKey,%RelationKey)               #<!Set to keyed order
  283.   LOOP                                           !Get all selected records
  284.     NEXT(%Primary)                             #<!Get the next record.
  285.     IF ERRORCODE() THEN BREAK.                   !Quit if an error occurs
  286.     #INSERT(%GetChildSecondary)
  287.   #FIX(%File,%Primary)
  288.   #FIX(%Key,%PrimaryKey)
  289.   #IF(%ChildRelationField)                      #!If using a Range
  290.     IF %ChildRelationField <> %ParentRelationField #<!If not in Range
  291.       BREAK                                    #<!  Break out of the Loop
  292.     END                                          !End IF
  293.   #ENDIF
  294.   #IF(%RecordFilterFormula)
  295.     IF ~(%RecordFilterFormula)                 #<!If Filter condition not met
  296.       CYCLE                                      ! Try another record
  297.     END                                          !End IF
  298.   #ELSE
  299.     #FOR(%Formula)
  300.       #IF(UPPER(%FormulaClass) = 'FILTER')
  301.         #IF(%FormulaType <> 'COMPUTED')
  302.     IF ~(%FormulaCondition)                    #<!If Filter condition not met
  303.       CYCLE                                      ! Try another record
  304.     END                                          !End IF
  305.         #ELSE
  306.     IF ~(%FormulaComputation)                  #<!If Filter condition not met
  307.       CYCLE                                      ! Try another record
  308.     END                                          !End IF
  309.         #ENDIF
  310.       #ENDIF
  311.     #ENDFOR
  312.   #ENDIF
  313.   #FOR(%Formula)
  314.     #IF(UPPER(%FormulaClass) = 'LIST')
  315.     #INSERT(%GenerateFormula)                   #!Generate LIST formulas
  316.     #ENDIF
  317.   #ENDFOR
  318.   #FIX(%File,%Primary)
  319.   #SET(%ListField,'?LIST')
  320.   #FIX(%ScreenField,%ListField)
  321.     SAV:Line = %ScreenFieldExpression          #<! Fill the DisplayQueue line
  322.     SAV:SaveRecord = %FilePre:Record             ! Save the record data
  323.     SAV:RecordPosition = POSITION(%Primary)
  324.     ADD(RecordQueue %SortString)               #<! Add to the sorted queue
  325.     IF ERRORCODE() THEN BREAK.                   ! Quit out if error
  326.     IF FirstPage                                 ! If page 1
  327.       IF RECORDS(RecordQueue) = ROWS(?List)      ! If we have a full screen
  328.         FirstPage = 0                            !   turn off the page flag
  329.       END                                        !  End IF
  330.       DISPLAY(?List)                             !  Display page 1
  331.     END                                          ! End IF
  332.   END                                            !End LOOP
  333.   IF RECORDS(RecordQueue) = %FixRows
  334.     IF RECORDS(%Primary)                       #<!If file is not empty
  335.       IF ?List <> 1                              ! And list is not first
  336.         SELECT(1)                                !  Select the first field
  337.       ELSE                                       ! Else
  338.         DISABLE(1,FIELDS())                      !  Disable all fields
  339.         ENABLE(?Insert)                          !  Enable the Insert and
  340.         ENABLE(?Cancel)                          !  the cancel buttons
  341.         SELECT(?Insert)                          !  Select the Insert Button
  342.       END                                        ! End IF
  343.     ELSE                                         ! If file is empty
  344.       DISABLE(1,FIELDS())                        !  Disable all fields
  345.       ENABLE(?Insert)                            !  Enable the Insert and
  346.       ENABLE(?Cancel)                            !  the cancel buttons
  347.       SELECT(?Insert)                            !  Select the Insert Button
  348.     END                                          ! End IF
  349.   END                                            !End IF
  350.   DISPLAY
  351. #!
  352. #!***************************************************************************
  353. #GROUP(%SetChildSymbols)
  354. #IF(%ParentFile = %Null)
  355.   #SET(%ErrorMessage, (%Procedure & ' ERROR: Parent File is required.'))
  356.   #ERROR(%ErrorMessage)
  357. #ENDIF
  358. #SET(%MemoExists,%Null)
  359. #FIX(%File,%Primary)
  360. #FIX(%File,%Primary)
  361. #FIX(%Relation,%ParentFile)
  362. #IF(%RelationType = 'MANY:1')
  363.   #FOR(%RelationKeyField)
  364.     #SET(%ParentRelationField, %RelationKeyField)
  365.     #SET(%ChildRelationField, %RelationKeyFieldLink)
  366.     #BREAK
  367.   #ENDFOR
  368. #ENDIF
  369. #SET(%ScreenFldSetupExists,%Null)
  370. #FIX(%File,%Primary)
  371. #FOR(%Field)
  372.   #IF(%FieldType = 'MEMO')
  373.     #SET(%MemoExists,'Yes')
  374.     #BREAK
  375.   #ENDIF
  376. #ENDFOR
  377. #SET(%FixRows, '0')
  378. #SET(%ListField,'?List')
  379. #FIX(%ScreenField,%ListField)
  380. #FOR(%ScreenFieldFix)
  381.   #SET(%FixRows, (%FixRows + 1))
  382. #ENDFOR
  383. #FOR(%ScreenField)
  384.   #IF(%ScreenFieldSetup)
  385.     #SET(%ScreenFldSetupExists,'YES')
  386.     #BREAK
  387.   #ENDIF
  388. #ENDFOR
  389. #SET(%FirstEntryField,%Null)
  390. #FOR(%ScreenField)
  391.   #IF(%ScreenFieldSkip = %Null)
  392.     #SET(%FirstEntryField,%ScreenField)
  393.     #BREAK
  394.   #ENDIF
  395. #ENDFOR
  396. #FOR(%Field)
  397.   #IF(%FieldInitial <> %NULL)
  398.     #SET(%InitRoutine,'TRUE')
  399.     #BREAK
  400.   #ENDIF
  401. #ENDFOR
  402. #!***************************************************************************
  403. #GROUP(%GetChildSecondary)
  404.   #FOR(%Secondary)                             #! for fields in the list box
  405.     #IF(%Secondary <> %ParentFile)
  406.       #IF(%SecondaryType = 'MANY:1')           #!Check for lookup files
  407.         #FIX(%File,%SecondaryTo)
  408.         #FIX(%Relation,%Secondary)
  409.         #FOR(%RelationKeyField)
  410. IF %RelationKeyField <> %RelationKeyFieldLink  #<!If Link fields don't match
  411.   %RelationKeyField = %RelationKeyFieldLink    #<! Assign linking field value
  412.         #ENDFOR
  413.   GET(%Secondary,%RelationKey)                 #<! Lookup record
  414.         #FIX(%File,%Secondary)
  415.   IF ERRORCODE() THEN CLEAR(%FilePre:Record).  #<! Clear record if unsuccessful
  416. END                                            #<!End IF
  417.       #ENDIF
  418.     #ENDIF
  419.   #ENDFOR
  420. #!***************************************************************************
  421. #GROUP(%ChildInitFields)
  422. #IF(%InitRoutine = 'TRUE')
  423. InitializeFields ROUTINE
  424. #FOR(%Field)
  425. #IF(%FieldInitial <> %NULL)
  426.   %Field = %FieldInitial
  427. #ENDIF
  428. #ENDFOR
  429. #ENDIF
  430. #!***************************************************************************
  431. #GROUP(%ChildEditRoutines)
  432.   #FOR(%ScreenField)
  433.     #IF(%ScreenFieldUse <> '?Ok')
  434.       #IF(%ScreenFieldUse <> '?Cancel')
  435.       #INSERT(%RangeLookupCheck)
  436.         #IF(%ScreenFieldEdit OR %RangeCodeOn OR %FieldLookupOn)
  437. OF %ScreenField
  438.           #IF(%FieldLookupOn)
  439.   #INSERT(%FieldLookupCode)
  440.           #ENDIF
  441.           #IF(%RangeCodeOn)
  442.   #INSERT(%RangeCode)
  443.           #ENDIF
  444.           #IF(%ScreenFieldEdit)
  445.   %ScreenFieldEdit
  446.           #ENDIF
  447.         #ENDIF
  448.       #ENDIF
  449.     #ENDIF
  450.   #ENDFOR
  451.   #FOR(%PulldownField)
  452.     #IF(%PulldownFieldProc <> %NULL)
  453. OF %PulldownField                              #<! For a selected menu item
  454.   %PulldownFieldProc                           #<! Call the procedure
  455.     #ENDIF
  456.   #ENDFOR
  457. #!***************************************************************************
  458. #GROUP(%NullParentCheck)
  459.   #IF(%NullParentExit)
  460.     #FIX(%File,%ParentFile)
  461. IF %FilePre:RECORD = ''                        #<!If Parent record is blank
  462.   RETURN                                       #<! Return to the caller
  463. END                                            #<!End IF
  464.     #FIX(%File,%Primary)
  465.   #ENDIF
  466. #!***************************************************************************
  467. #GROUP(%HoldParentRecord)
  468.   #IF(%SharedFiles)
  469. HOLD(%ParentFile,5)                            #<! When sharing the files
  470. IF ERRORCODE() = isLockedErr                   #<! Hold the parent record.
  471.   GLO:Message1 = 'This %ParentFile Entry is being updated'
  472.   GLO:Message2 = 'by another user.    Try again later. '
  473.   GLO:Message3 = ''                            #<!  Show an error if another
  474.   ShowWarning                                  #<!  user has the parent held
  475.   RETURN                                       #<!  and exit
  476. END                                            #<! End IF
  477.   #ENDIF
  478. #!***************************************************************************
  479. #GROUP(%UpdateChildRecords)
  480. #FIX(%File,%Primary)
  481. LOOP                                           #<!For child records
  482.   NEXT(%Primary)                               #<! Get the next record
  483.   IF ERRORCODE()                               #<! IF Reading past EOF()
  484.     BREAK                                      #<!  BREAK out of the LOOP
  485.   ELSIF %ChildRelationField <> %ParentRelationField #<! or no child records
  486.     BREAK                                      #<!  BREAK out of the LOOP
  487.   END                                          #<! End IF
  488.   SAV:SaveRecord = %FilePre:RECORD             #<! Fill the Queue
  489.   GET(RecordQueue %SortString)                 #<! Get the matching QUEUE
  490.   IF ERRORCODE()                               #<! If Not found
  491.     DELETE(%Primary)                           #<!  Delete the file entry
  492.   ELSIF SAV:SaveRecord <> %FilePre:RECORD      #<! Else if Records don't match
  493.     DELETE(%Primary)                           #<!  Delete the file entry
  494.   ELSE                                         #<! Else
  495.     SAV:SkipRecord = 1                         #<!  Mark QUEUE record as skip
  496.     PUT(RecordQueue %SortString)               #<!  and PUT() back in QUEUE
  497.   END                                          #<! End IF
  498.   IF ERRORCODE()                               #<! If error on delete or PUT
  499.     TransactionError = ERRORCODE()             #<!  Save the error code
  500.     BREAK                                      #<!  and BREAK out of the loop
  501.   END                                          #<! End IF
  502. END                                            #<!End LOOP
  503. RecordEntryOne = %FixRows + 1                  #<!
  504. LOOP I = RecordEntryOne TO QRecs               #<! Loop through Queue
  505.   GET(RecordQueue,I)                           #<!  Get a QUEUE Element
  506.   IF ERRORCODE() THEN STOP(ERROR()).           #<!  Stop if Unexpected error
  507.   IF SAV:SkipRecord THEN CYCLE.                #<!  Skip unmodified records
  508.   %FilePre:RECORD = SAV:SaveRecord             #<!  Restore the Record
  509.   #FOR(%Field)
  510.     #IF(%FieldType = 'MEMO')
  511.       #SET(%MemoField,%FieldID)
  512.   %FilePre:%FieldID = SAV:%FieldID             #<!  Restore the Memos
  513.     #ENDIF
  514.   #ENDFOR
  515.   ADD(%Primary)                                #<!  Add to the file.
  516.   IF ERRORCODE()                               #<!  If error during ADD
  517.     TransactionError = ERRORCODE()             #<!    Save the error
  518.     BREAK                                      #<!    and break from the loop
  519.   END                                          #<!  End IF
  520. END                                            #<! End LOOP
  521. #!***************************************************************************
  522. #GROUP(%PutParentFile)
  523.   #IF(%SharedFiles)
  524.     #IF(%PutParent)
  525. PUT(%ParentFile)                               #<!Put the parent record
  526. IF ERRORCODE()
  527.   GLO:Message1 = 'Unable to save %ParentFile Entry.'
  528.   GLO:Message2 = 'Error: '& ERROR()
  529.   GLO:Message3 = 'The entry has not been saved.' #<!Show an error if another
  530.   ShowWarning                                  #<!Show the transaction error
  531. END
  532.     #ELSE
  533. RELEASE(%ParentFile)                           #<!Release the held record
  534.     #ENDIF
  535.   #ENDIF
  536. #!***************************************************************************
  537. #GROUP(%FillQueueFields)
  538. #FIX(%File, %ParentFile)
  539. #FIX(%Relation,%Primary)
  540. #IF(%RelationType = '1:MANY')
  541.   #FOR(%RelationKeyField)
  542.     #IF(%RelationKeyFieldLink)
  543. %RelationKeyField = %RelationKeyFieldLink      #<!Assign linking field value
  544.     #ENDIF
  545.   #ENDFOR
  546. #ENDIF
  547. SAV:Line = %ScreenFieldExpression              #<! Fill the DisplayQueue line
  548. #FIX(%File, %Primary)
  549. SAV:SaveRecord = %FilePre:RECORD               #<! Fill the QUEUE Record
  550. #FOR(%Field)
  551.   #IF(%FieldType = 'MEMO')
  552.   #SET(%MemoField,%FieldID)
  553.   SAV:%FieldID = %FilePre:%FieldID             #<! Fill the QUEUE Memo
  554.   #ENDIF
  555. #ENDFOR
  556. #!***************************************************************************
  557. #CHAIN('OM7.TPX')
  558.