home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
High Voltage Shareware
/
high1.zip
/
high1
/
DIR36
/
C7101.ZIP
/
CHLDGRPS.TPX
< prev
next >
Wrap
Text File
|
1994-01-12
|
9KB
|
205 lines
#!┌───────────────────────────┤Template Segment├───────────┬─────────────────┐
#!│ ChldGrps.TPX │Version: 3007.000│
#!├───────────────────────────────┤Contents├───────────────┴─────────────────┤
#!│Structure Type Description │
#!│──────────────────── ───────── ─────────────────────────────────────────│
#!│SetChildSymbols GROUP Setup Code Generation Flags │
#!│GetChildSecondary GROUP Perform Many:1 Lookups │
#!│ChildInitFields GROUP Initialize Fields for INSERTed record │
#!│NullParentCheck GROUP Check if Parent is Empty │
#!│HoldParentRecord GROUP Hold parent Rec during execution of CHILD│
#!│UpdateChildRecords GROUP Perform update to CHILD records │
#!│PutParentFile GROUP Put parent after execution of CHILD │
#!│FillQueueFields GROUP Fill up the List Box │
#!├───────────────────────────────┤Comments├─────────────────────────────────┤
#!│Version Comments │
#!│──────── ────────────────────────────────────────────────────────────────│
#!│3007.000 Release of CDD3 version 3007 templates │
#!└──────────────────────────────────────────────────────────────────────────┘
#!
#GROUP(%SetChildSymbols)
#IF(%ParentFile = %Null)
#SET(%ErrorMessage, (%Procedure & ' ERROR: Parent File is required.'))
#ERROR(%ErrorMessage)
#ENDIF
#SET(%MemoExists,%Null)
#FIX(%File,%Primary)
#FIX(%Relation,%ParentFile)
#IF(%RelationType = 'MANY:1')
#FOR(%RelationKeyField)
#SET(%ParentRelationField, %RelationKeyField)
#SET(%ChildRelationField, %RelationKeyFieldLink)
#BREAK
#ENDFOR
#ENDIF
#SET(%ScreenFldSetupExists,%Null)
#FIX(%File,%Primary)
#FOR(%Field)
#IF(%FieldType = 'MEMO')
#SET(%MemoExists,'Yes')
#BREAK
#ENDIF
#ENDFOR
#SET(%FixRows, '0')
#SET(%ListField,'?List')
#FIX(%ScreenField,%ListField)
#FOR(%ScreenFieldFix)
#SET(%FixRows, (%FixRows + 1))
#ENDFOR
#FOR(%ScreenField)
#IF(%ScreenFieldSetup)
#SET(%ScreenFldSetupExists,'YES')
#BREAK
#ENDIF
#ENDFOR
#SET(%FirstEntryField,%Null)
#FOR(%ScreenField)
#IF(%ScreenFieldSkip = %Null)
#SET(%FirstEntryField,%ScreenField)
#BREAK
#ENDIF
#ENDFOR
#FOR(%Field)
#IF(%FieldInitial <> %NULL)
#SET(%InitRoutine,'TRUE')
#BREAK
#ENDIF
#ENDFOR
#!***************************************************************************
#GROUP(%GetChildSecondary)
#FOR(%Secondary) #! for fields in the list box
#IF(%Secondary <> %ParentFile)
#IF(%SecondaryType = 'MANY:1') #!Check for lookup files
#FIX(%File,%SecondaryTo)
#FIX(%Relation,%Secondary)
#FOR(%RelationKeyField)
IF %RelationKeyField <> %RelationKeyFieldLink #<!If Link fields don't match
%RelationKeyField = %RelationKeyFieldLink #<! Assign linking field value
END #<!End IF
#ENDFOR
GET(%Secondary,%RelationKey) #<! Lookup record
#FIX(%File,%Secondary)
IF ERRORCODE() #<! Clear record if unsuccessful
#INSERT(%ClearFileFields)
END
#ENDIF
#ENDIF
#ENDFOR
#!***************************************************************************
#GROUP(%ChildInitFields)
#IF(%InitRoutine = 'TRUE')
InitializeFields ROUTINE
#FOR(%Field)
#IF(%FieldInitial <> %NULL)
%Field = %FieldInitial
#ENDIF
#ENDFOR
#ENDIF
#!***************************************************************************
#GROUP(%NullParentCheck)
#IF(%NullParentExit)
#FIX(%File,%ParentFile)
IF %FilePre:RECORD = '' #<!If Parent record is blank
RETURN #<! Return to the caller
END #<!End IF
#FIX(%File,%Primary)
#ENDIF
#!***************************************************************************
#GROUP(%HoldParentRecord)
#IF(%SharedFiles)
HOLD(%ParentFile,5) #<! When sharing the files
IF ERRORCODE() = isLockedErr #<! Hold the parent record.
#INSERT(%ParentLockedMsg)
RETURN #<! and exit
END #<! End IF
#ENDIF
#!***************************************************************************
#GROUP(%UpdateChildRecords)
#FIX(%File,%Primary)
#FIX(%Relation,%ParentFile)
LOOP #<!For child records
NEXT(%Primary) #<! Get the next record
IF ERRORCODE() #<! IF Reading past EOF()
BREAK #<! BREAK out of the LOOP
#FOR(%RelationKeyField)
#IF(%RelationKeyFieldLink)
ELSIF %RelationKeyFieldLink <> %RelationKeyField #<! or no child records
BREAK #<! BREAK out of the LOOP
#ENDIF
#ENDFOR
END #<! End IF
SAV:SaveRecord = %FilePre:RECORD #<! Fill the Queue
GET(RecordQueue %SortString) #<! Get the matching QUEUE
IF ERRORCODE() #<! If Not found
DELETE(%Primary) #<! Delete the file entry
ELSIF SAV:SaveRecord <> %FilePre:RECORD #<! Else if Records don't match
DELETE(%Primary) #<! Delete the file entry
#FOR(%Field)
#IF(%FieldType = 'MEMO')
ELSIF SAV:%FieldID <> %Field #<! Else if Records don't match
DELETE(%Primary) #<! Delete the file entry
#ENDIF
#ENDFOR
ELSE #<! Else
SAV:SkipRecord = 1 #<! Mark QUEUE record as skip
PUT(RecordQueue %SortString) #<! and PUT() back in QUEUE
END #<! End IF
IF ERRORCODE() #<! If error on delete or PUT
TransactionError = ERRORCODE() #<! Save the error code
BREAK #<! and BREAK out of the loop
END #<! End IF
END #<!End LOOP
RecordEntryOne = %FixRows + 1 #<!
LOOP I = RecordEntryOne TO QRecs #<! Loop through Queue
GET(RecordQueue,I) #<! Get a QUEUE Element
IF ERRORCODE() THEN STOP(ERROR()). #<! Stop if Unexpected error
IF SAV:SkipRecord THEN CYCLE. #<! Skip unmodified records
%FilePre:RECORD = SAV:SaveRecord #<! Restore the Record
#FOR(%Field)
#IF(%FieldType = 'MEMO')
#SET(%MemoField,%FieldID)
%Field = SAV:%FieldID #<! Restore the Memos
#ENDIF
#ENDFOR
ADD(%Primary) #<! Add to the file.
IF ERRORCODE() #<! If error during ADD
TransactionError = ERRORCODE() #<! Save the error
BREAK #<! and break from the loop
END #<! End IF
END #<! End LOOP
#!***************************************************************************
#GROUP(%PutParentFile)
#IF(%SharedFiles)
#IF(%PutParent)
PUT(%ParentFile) #<!Put the parent record
IF ERRORCODE()
#INSERT(%ParentWriteErrMsg)
END
#ELSE
RELEASE(%ParentFile) #<!Release the held record
#ENDIF
#ENDIF
#!***************************************************************************
#GROUP(%FillQueueFields)
#FIX(%File, %ParentFile)
#FIX(%Relation,%Primary)
#IF(%RelationType = '1:MANY')
#FOR(%RelationKeyField)
#IF(%RelationKeyFieldLink)
%RelationKeyField = %RelationKeyFieldLink #<!Assign linking field value
#ENDIF
#ENDFOR
#ENDIF
#FIX(%ScreenField,'?List')
SAV:Line = %ScreenFieldExpression #<! Fill the DisplayQueue line
#FIX(%File, %Primary)
SAV:SaveRecord = %FilePre:RECORD #<! Fill the QUEUE Record
#FOR(%Field)
#IF(%FieldType = 'MEMO')
#SET(%MemoField,%FieldID)
SAV:%FieldID = %Field #<! Fill the QUEUE Memo
#ENDIF
#ENDFOR
#!***************************************************************************
#CHAIN('FormGrps.TPX')