home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
High Voltage Shareware
/
high1.zip
/
high1
/
DIR2
/
CLATPL.ZIP
/
CLARION3.TPX
< prev
next >
Wrap
Text File
|
1993-07-26
|
87KB
|
2,085 lines
!------------------------------------------------------------------------------
#!
#! CLARION3.TPX
#!
#! Browse Scroll records from a file one page at a time
#! List Scroll records from a file from a memory queue
#! Lookup Lookup a field value from a file
#! Select Load a selected record into memory
#! Validate Validate an entry field
#!
#!------------------------------------------------------------------------------
#!
#PROCEDURE(Browse,'Scroll records from a file'),SCREEN,PULLDOWN
#!------------------------------------------------------------------------------
#!
#! The Browse Template
#!
#!------------------------------------------------------------------------------
#PROMPT('Range &Limit Field',COMPONENT),%KeyRangeField
#PROMPT('Range &Value Field',FIELD),%RangeValue
#PROMPT('Record Filter',@S180),%RecordFilter
#PROMPT('Locator Field',COMPONENT),%Locator
#PROMPT('Upd&ate Procedure',PROCEDURE),%UpdateProc
#PROMPT('First &Hot Field',FIELD),%First
#PROMPT('Last &Hot Field',FIELD),%Last
#PROMPT('Enable Hot Records',CHECK),%HotBar
#INSERT(%StandardHeader)
#MAP('BROWSE.INC')
#PROJECT('%clapfx%BROWS.LIB')
#PROTOTYPE('')
%Procedure PROCEDURE
#INSERT(%SetBrowseSymbols)
#INSERT(%BrowseErrorCheck)
#!
#FIX(%ScreenField,'?List')
Queue QUEUE
STRING(%ScreenFieldQueueSize)
.
#IF(%KeyRangeField)
#FIX(%Key,%PrimaryKey)
#SET(%Found, %Null)
#FOR(%KeyField)
#IF(%Found <> 'Yes')
SAV::%KeyField Like(%KeyField)
#ENDIF
#IF(%KeyField = %KeyRangeField)
#SET(%Found, 'Yes')
#ENDIF
#ENDFOR
#ENDIF
ButtonIsDisabled BYTE !Flag to allow button enable
#INSERT(%CloseFilesFlags)
%LocalData
%ScreenStructure
%PulldownStructure
#EMBED('Data Section')
CODE
#EMBED('Setup Procedure')
#FIX(%File,%Primary)
#INSERT(%OpenPrimary)
#INSERT(%OpenSecondaryFiles)
FREE(Queue) !Make sure Queue is empty
OPEN(Screen) !Open the screen
#EMBED('Setup Screen')
DISPLAY !Display screen fields
#INSERT(%SaveRangeFields)
#IF(%Pulldown) #!If a Pulldown exists
OPEN(%Pulldown) #<!Open the Pulldown
#ENDIF
#INSERT(%AddFixedListLines)
#INSERT(%BeginBrowse)
LOOP !Process browse requests
CASE BrowseAction(%Primary,%PrimaryKey,Queue)#<!Browse the file
OF FormatQueue !Format a queue element
#INSERT(%GetSecondaryRecords)
#FOR(%Formula)
#IF(UPPER(%FormulaClass) = 'LIST')
#INSERT(%GenerateFormula)
#ENDIF
#ENDFOR
#EMBED('LIST Class formula')
#FIX(%ScreenField,'?List')
Queue = %ScreenFieldExpression #<!Format the listbox queue
OF ProcessField !Process a field
#FOR(%Formula)
#IF(UPPER(%FormulaClass) <> 'LIST')
#IF(UPPER(%FormulaClass) <> 'FILTER')
#INSERT(%GenerateFormula)
#ENDIF
#ENDIF
#ENDFOR
#EMBED('End of General Formulas')
#IF(%HotKeyExists)
CASE KEYCODE() !User defined hotkey check
#FOR(%HotKey)
OF %HotKey #<!User defined HotKey
%HotKeyProc #<!HotKey Procedure
#ENDFOR
END !End CASE
#ENDIF
IF SELECTED() <> FIELD() ! If a new field is selected
CASE SELECTED() ! Jump to setup routine
#IF(%KeyRangeField)
OF ?List
#INSERT(%SaveRangeFields)
#ENDIF
#INSERT(%ScreenSetupRoutines)
END ! End CASE SELECTED()
END ! End IF
CASE FIELD() !Jump to edit routine
#FOR(%ScreenField)
#IF(%ScreenField = '?Insert')
#IF(%UpdateProc)
OF ?Insert !Process the Insert Button
#IF(%ScreenFieldEdit)
%ScreenFieldEdit #<! Insert button Edit Routine
#ENDIF
#INSERT(%ClearFileFields)
#INSERT(%RestoreRangeFields)
SETKEYCODE(InsKey) ! Set action to Insert
Do UpdateProcedure ! Call the update procedure
SELECT(?List) ! Reselect the List field
#ENDIF
#ELSIF(%ScreenField = '?Change')
#IF(%UpdateProc)
OF ?Change !Process the Change Button
#IF(%ScreenFieldEdit)
%ScreenFieldEdit #<! Change button Edit Routine
#ENDIF
SETKEYCODE(EnterKey) ! Set action to Change
Do UpdateProcedure ! Call the update procedure
SELECT(?List) ! Reselect the List field
#ENDIF
#ELSIF(%ScreenField = '?Delete')
#IF(%UpdateProc)
OF ?Delete !Process the Delete Button
#IF(%ScreenFieldEdit)
%ScreenFieldEdit #<! Delete button Edit Routine
#ENDIF
SETKEYCODE(DelKey) ! Set action to Delete
DO UpdateProcedure ! Call the update procedure
SELECT(?List) ! Reselect the List field
#ENDIF
#ELSIF(%ScreenField = '?List')
#IF(%UpdateProc)
OF ?List !Process the list field
CASE KEYCODE() ! Jump to keycode routine
#IF(%NoButtonsExist OR %InsertExists)
OF InsKey ! For the insert key
#INSERT(%ClearFileFields)
#INSERT(%RestoreRangeFields)
DO UpdateProcedure ! Call the update procedure
#ENDIF
#IF(%NoButtonsExist OR %DeleteExists)
OF DelKey ! For the delete key
DO UpdateProcedure ! Call the update procedure
#ENDIF
#IF(%NoButtonsExist OR %ChangeExists )
OF EnterKey ! Or the enter key
OROF MouseLeft2 ! Or a double mouse click
DO UpdateProcedure ! Call the update procedure
#ENDIF
END ! End CASE
#ENDIF
#ELSIF(%ScreenField = '?Exit')
OF ?Exit !Process the Exit button
#IF(%ScreenFieldEdit)
%ScreenFieldEdit #<! Exit button Edit Routine
#ENDIF
BREAK ! Return to caller
#ELSIF(%ScreenFieldEdit)
OF %ScreenField #<! Completed %ScreenField
%ScreenFieldEdit #<! %ScreenField edit routine
#ENDIF
#ENDFOR
#INSERT(%PulldownEditRoutines)
END !End CASE FIELD()
OF NoRecords !No records to browse
#INSERT(%ClearFileFields)
#INSERT(%RestoreRangeFields)
DISPLAY
#IF(%ChangeExists)
DISABLE(?Change) ! Disable the change button
#ENDIF
#IF(%DeleteExists)
DISABLE(?Delete) ! Disable the delete button
#ENDIF
ButtonIsDisabled = TRUE
IF RECORDS(%Primary) #<! If file is not empty
IF ?List <> %FirstEntryField #<! And list is not first
SELECT(%FirstEntryField) #<! Select the first field
ELSE ! Else
#IF(%UpdateProc)
#IF(%InsertExists)
SELECT(?Insert) ! Select the Insert Button
#ELSE
#INSERT(%RestoreRangeFields)
SETKEYCODE(InsKey) ! Ask for a new record
DO UpdateProcedure ! Call the update procedure
IF POSITION(%PrimaryKey) = '' #<! If record not added
BREAK ! Return to caller
ELSE ! Else record was added
#IF(%ChangeExists)
ENABLE(?Change) ! Disable the change button
#ENDIF
#IF(%DeleteExists)
ENABLE(?Delete) ! Disable the delete button
#ENDIF
ButtonIsDisabled = FALSE
END ! End IF
#ENDIF
#ELSE
BREAK ! Return to caller
#ENDIF
END ! End IF
ELSE ! Else if file is empty
#IF(%UpdateProc)
#INSERT(%RestoreRangeFields)
SETKEYCODE(InsKey) ! Ask for a new record
DO UpdateProcedure ! Call the update procedure
IF POSITION(%PrimaryKey) = '' #<! If record not added
BREAK ! Return to caller
ELSE ! Else record was added
#IF(%ChangeExists)
ENABLE(?Change) ! Disable the change button
#ENDIF
#IF(%DeleteExists)
ENABLE(?Delete) ! Disable the delete button
#ENDIF
ButtonIsDisabled = FALSE
END ! End IF
#ELSE
BREAK ! Return to caller
#ENDIF
END ! End IF
#IF(%FilterExists OR %KeyRangeField)
OF FilterRecord !Should we add this record
IF ButtonIsDisabled
#IF(%ChangeExists)
ENABLE(?Change) ! Enable the change button
#ENDIF
#IF(%DeleteExists)
ENABLE(?Delete) ! Enable the delete button
#ENDIF
ButtonIsDisabled = FALSE
END
#IF(%KeyRangeField) #!If using range limits
#IF(%RangeValue) #! If using range value field
IF (%KeyRangeField <> %RangeValue) #<! If range field has changed
PREVIOUS(%Primary) #<! Signal browse to build
#INSERT(%ClearFileFields) #! Clear for screen fields
CYCLE ! Cycle for BrowseAction
END ! End IF
#ELSE
#SET(%Found, %Null)
#FOR(%KeyField)
#IF(%Found <> 'Yes')
IF (%KeyField <> SAV::%KeyField) #<! If range field has changed
PREVIOUS(%Primary) #<! Signal browse to build
#INSERT(%ClearFileFields) #! Clear for screen fields
CYCLE ! Cycle for BrowseAction
END ! End IF
#ENDIF
#IF(%KeyField = %KeyRangeField)
#SET(%Found, 'Yes')
#ENDIF
#ENDFOR
#ENDIF
#ENDIF
#IF(%RecordFilter)
IF ~(%RecordFilter) #<!If Filter condition not met
GET(%Primary,0) #<! Dereference the record
CYCLE ! Return to Top of LOOP
END !End IF
#ELSE
#FOR(%Formula)
#IF(UPPER(%FormulaClass) = 'FILTER')
#IF(%FormulaType <> 'COMPUTED')
IF ~(%FormulaCondition) #<!If Filter condition not met
GET(%Primary,0) #<! Dereference the record
CYCLE ! Return to Top of LOOP
END !End IF
#ELSE
IF ~(%FormulaComputation) #<!If Filter condition not met
GET(%Primary,0) #<! Dereference the record
CYCLE ! Return to Top of LOOP
END !End IF
#ENDIF
#ENDIF
#ENDFOR
#ENDIF
#EMBED('After Filter and Range Check')
#ENDIF
#IF(%KeyRangeField)
OF ResetFirst !Set to first in a Range
CLEAR(%FilePre:RECORD,-1)
#INSERT(%RestoreRangeFields)
SET(%PrimaryKey,%PrimaryKey) #<! SET to the closest match
#EMBED('Set to First Record')
OF ResetLast !Set to last in a Range
CLEAR(%FilePre:RECORD,1)
#INSERT(%RestoreRangeFields)
SET(%PrimaryKey,%PrimaryKey) #<! SET to the closest match
#EMBED('Set to Last Record')
#ENDIF
#IF(%HotBar OR %First)
OF ProcessSelected !Process highlighted record
#INSERT(%GetSecondaryRecords)
#FOR(%Formula)
#IF(UPPER(%FormulaClass) <> 'FILTER')
#INSERT(%GenerateFormula)
#ENDIF
#ENDFOR
#EMBED('Process Selected Record')
#IF(%First AND %Last)
DISPLAY(?%First,?%Last) #<! Display the hot fields
#ELSIF(%First)
DISPLAY(?%First) #<! Display the hot fields
#ENDIF
#ENDIF
END ! End CASE
END !End LOOP
EndBrowse !End the browse session
FREE(Queue) !Free the Queue memory
#IF(%Pulldown) #!If a Pulldown exists
CLOSE(%Pulldown) #<!Close the Pulldown
#ENDIF
#INSERT(%CloseOpenedFiles)
#EMBED('End of Procedure')
#IF(%UpdateProc)
UpdateProcedure ROUTINE
#EMBED('Prior to Update Procedure')
%UpdateProc
#EMBED('After Update Procedure')
#ENDIF
#!
#PROCEDURE(Lookup,'Lookup a field value from a file'),SCREEN,PULLDOWN
#!------------------------------------------------------------------------------
#!
#! The Lookup Template
#!
#! A Lookup procedure must be called as a Setup Procedure
#!
#!------------------------------------------------------------------------------
#PROMPT('Range &Limit Field',COMPONENT),%KeyRangeField
#PROMPT('Range &Value Field',FIELD),%RangeValue
#PROMPT('Record Filter',@S180),%RecordFilter
#PROMPT('Lookup Field',COMPONENT),%LookupField
#PROMPT('Input Field Picture',@S30),%LookupPicture
#PROMPT('Locator Field',COMPONENT),%Locator
#PROMPT('Display Key',KEY),%DisplayKey
#PROMPT('Upd&ate Procedure',PROCEDURE),%UpdateProc
#PROMPT('First &Hot Field',FIELD),%First
#PROMPT('Last &Hot Field',FIELD),%Last
#PROMPT('Enable Hot Records',CHECK),%HotBar
#!
#MAP('BROWSE.INC')
#PROJECT('%clapfx%BROWS.LIB')
#PROTOTYPE('')
#INSERT(%SetBrowseSymbols)
#INSERT(%BrowseErrorCheck)
#FIX(%File,%Primary)
#SET(%LookupKey,%PrimaryKey)
#FIX(%Field,%LookupField)
#IF(%FieldType = 'STRING'OR %FieldType = 'CSTRING'OR %FieldType = 'PSTRING')
#SET(%LookupType,'STRING')
#ENDIF
#IF(%DisplayKey = %Null)
#SET(%DisplayKey, %PrimaryKey)
#ENDIF
#!
#INSERT(%StandardHeader)
%Procedure PROCEDURE
#FIX(%ScreenField,'?List')
Queue QUEUE
STRING(%ScreenFieldQueueSize)
END
#IF(%KeyRangeField)
#FIX(%Key,%PrimaryKey)
#SET(%Found, %Null)
#FOR(%KeyField)
#IF(%Found <> 'Yes')
SAV::%KeyField Like(%KeyField)
#ENDIF
#IF(%KeyField = %KeyRangeField)
#SET(%Found, 'Yes')
#ENDIF
#ENDFOR
#ENDIF
#IF(%LookupPicture)
DeformatString STRING(80)
#ENDIF
ButtonIsDisabled BYTE !Flag to allow button enable
#INSERT(%CloseFilesFlags)
%LocalData
%ScreenStructure
%PulldownStructure
#EMBED('Data Section')
CODE
#EMBED('Setup Procedure')
#FIX(%File,%Primary)
#INSERT(%OpenPrimary)
#SET(%FromLookup, 'TRUE')
#INSERT(%LookupRecord)
#INSERT(%OpenSecondaryFiles)
FREE(Queue) !Make sure Queue is empty
OPEN(Screen) !Open the screen
#EMBED('Setup Screen')
DISPLAY !Display screen fields
#INSERT(%SaveRangeFields)
#IF(%Pulldown) #!If a Pulldown exists
OPEN(%Pulldown) #<!Open the Pulldown
#ENDIF
#INSERT(%AddFixedListLines)
#INSERT(%BeginBrowse)
LOOP !Process browse requests
CASE BrowseAction(%Primary,%DisplayKey,Queue)#<!Browse the file
OF FormatQueue !Format a queue element
#INSERT(%GetSecondaryRecords)
#FOR(%Formula)
#IF(UPPER(%FormulaClass) = 'LIST')
#INSERT(%GenerateFormula)
#ENDIF
#ENDFOR
#EMBED('LIST Class formula')
#FIX(%ScreenField,'?List')
Queue = %ScreenFieldExpression
OF ProcessField !Process a field
#FOR(%Formula)
#IF(UPPER(%FormulaClass) <> 'LIST')
#INSERT(%GenerateFormula)
#ENDIF
#ENDFOR
#EMBED('End of General Formulas')
#IF(%HotKeyExists)
CASE KEYCODE()
#FOR(%HotKey)
OF %HotKey !User defined HotKey
%HotKeyProc !HotKey Procedure
#ENDFOR
END
#ENDIF
IF SELECTED() <> FIELD() ! If a new field is selected
CASE SELECTED() ! Jump to setup routine
#IF(%KeyRangeField)
OF ?List
#INSERT(%SaveRangeFields)
#ENDIF
#INSERT(%ScreenSetupRoutines)
END ! End CASE SELECTED()
END ! End IF
CASE FIELD() !Jump to edit routine
#FOR(%ScreenField)
#IF(%ScreenField = '?List')
OF ?List !Process the list field
CASE KEYCODE() !Jump to keycode routine
#IF(%UpdateProc)
#IF(%NoButtonsExist OR %InsertExists)
OF InsKey !For the insert key
#INSERT(%ClearFileFields)
Do UpdateProcedure ! Call the update procedure
#ELSIF(%ChangeExists <> 'YES')
OF InsKey !For the insert key
#INSERT(%ClearFileFields)
Do UpdateProcedure ! Call the update procedure
#ENDIF
#IF(%ChangeExists)
OF CtrlEnter !Or the Ctrl-Enter key
Do UpdateProcedure ! Call the update procedure
#ELSIF(%InsertExists <> 'YES')
OF CtrlEnter !Or the Ctrl-Enter key
Do UpdateProcedure ! Call the update procedure
#ENDIF
#ENDIF
OF MouseLeft2 !On mouse double click
OROF EnterKey !or the enter key
SELECT(?Select) ! Select the Select button
PRESS(EnterKey) ! And complete it.
END !End CASE
#ELSIF(%ScreenField = '?Insert')
#IF(%UpdateProc)
OF ?Insert !Process the Insert Button
#IF(%ScreenFieldEdit)
%ScreenFieldEdit #<!Insert button Edit Routine
#ENDIF
#INSERT(%ClearFileFields)
#INSERT(%RestoreRangeFields)
SETKEYCODE(InsKey) !Set action to Insert
Do UpdateProcedure ! Call the update procedure
SELECT(?List) !Reselect the List field
#ENDIF
#ELSIF(%ScreenField = '?Change')
#IF(%UpdateProc)
OF ?Change !Process the Change Button
#IF(%ScreenFieldEdit)
%ScreenFieldEdit #<!Change button Edit Routine
#ENDIF
SETKEYCODE(EnterKey) !Set action to Change
Do UpdateProcedure ! Call the update procedure
SELECT(?List) !Reselect the List field
#ENDIF
#ELSIF(%ScreenField = '?Select')
OF ?Select !Process the Select button
#IF(%ScreenFieldEdit)
%ScreenFieldEdit #<!Select button Edit Routine
#ENDIF
#IF(%Pulldown) #!If a Pulldown exists
CLOSE(%Pulldown) #<!Close the Pulldown
#ENDIF
CLOSE(Screen) !Close the screen
ERASE(SELECTED()) !Erase the old field contents
#IF(%LookupPicture)
PRESS(CLIP(LEFT(FORMAT(%LookupField,%LookupPicture)))) #<! Type in the field value
#ELSIF(%LookupType = 'STRING')
PRESS(CLIP(LEFT(%LookupField))) #<!Type in the field value
#ELSE
PRESS(CLIP(LEFT(FORMAT(%LookupField,@N15))))#<!Type in the field value
#ENDIF
PRESS(TabKey) ! and a tab key
BREAK !Return to caller
#ELSIF(%ScreenFieldEdit)
OF %ScreenField #<! Completed %ScreenField
%ScreenFieldEdit #<! %ScreenField edit routine
#ENDIF
#ENDFOR
#INSERT(%PulldownEditRoutines)
END !End CASE FIELD()
OF NoRecords !No records to browse
#INSERT(%ClearFileFields)
#INSERT(%RestoreRangeFields)
DISPLAY
#IF(%ChangeExists)
DISABLE(?Change) ! Disable the change button
#ENDIF
#IF(%DeleteExists)
DISABLE(?Delete) ! Disable the delete button
#ENDIF
ButtonIsDisabled = TRUE
IF RECORDS(%Primary) #<!If file is not empty
IF ?List <> %FirstEntryField #<! And list is not first
SELECT(%FirstEntryField) #<! Select the first field
ELSE ! End IF
#IF(%UpdateProc)
#IF(%InsertExists)
SELECT(?Insert) ! Select the Insert Button
#ELSE
#INSERT(%RestoreRangeFields)
SETKEYCODE(InsKey) ! Ask for a new record
Do UpdateProcedure ! Call the update procedure
IF POSITION(%DisplayKey) = '' ! If record not added
BREAK ! Return to caller
END ! End IF
#ENDIF
#ELSE
BREAK ! Return to caller
#ENDIF
END ! End IF
ELSE !If file is empty
#IF(%UpdateProc)
#INSERT(%RestoreRangeFields)
SETKEYCODE(InsKey) ! Ask for a new record
Do UpdateProcedure ! Call the update procedure
IF POSITION(%DisplayKey) = '' #<! If record not added
BREAK ! Return to caller
END ! End IF
#ELSE
BREAK ! Return to caller
#ENDIF
END !End IF
#IF(%FilterExists OR %KeyRangeField)
OF FilterRecord !Should we add this record
IF ButtonIsDisabled
#IF(%ChangeExists)
ENABLE(?Change) ! Enable the change button
#ENDIF
#IF(%DeleteExists)
ENABLE(?Delete) ! Enable the delete button
#ENDIF
ButtonIsDisabled = FALSE
END
#IF(%KeyRangeField) #!If using range limits
#IF(%RangeValue) #! If using range value field
IF (%KeyRangeField <> %RangeValue) #<! If range field has changed
PREVIOUS(%Primary) #<! Signal browse to build
#INSERT(%ClearFileFields) #! Clear for screen fields
CYCLE ! Cycle for BrowseAction
END ! End IF
#ELSE
#SET(%Found, %Null)
#FOR(%KeyField)
#IF(%Found <> 'Yes')
IF (%KeyField <> SAV::%KeyField) #<! If range field has changed
PREVIOUS(%Primary) #<! Signal browse to build
#INSERT(%ClearFileFields) #! Clear for screen fields
CYCLE ! Cycle for BrowseAction
END ! End IF
#ENDIF
#IF(%KeyField = %KeyRangeField)
#SET(%Found, 'Yes')
#ENDIF
#ENDFOR
#ENDIF
#ENDIF
#IF(%RecordFilter)
IF ~(%RecordFilter) #<!If Filter condition not met
GET(%Primary,0) #<! Dereference the record
CYCLE ! Return to Top of LOOP
END !End IF
#ELSE
#FOR(%Formula)
#IF(UPPER(%FormulaClass) = 'FILTER')
#IF(%FormulaType <> 'COMPUTED')
IF ~(%FormulaCondition) #<!If Filter condition not met
GET(%Primary,0) #<! Dereference the record
CYCLE ! Return to Top of LOOP
END !End IF
#ELSE
IF ~(%FormulaComputation) #<!If Filter condition not met
GET(%Primary,0) #<! Dereference the record
CYCLE ! Return to Top of LOOP
END !End IF
#ENDIF
#ENDIF
#ENDFOR
#ENDIF
#EMBED('After Filter and Range Check')
#ENDIF
#IF(%KeyRangeField)
OF ResetFirst !Set to first in a Range
CLEAR(%FilePre:RECORD,-1)
#INSERT(%RestoreRangeFields)
SET(%PrimaryKey,%PrimaryKey) #<! SET to the closest match
#EMBED('Set to First Record')
OF ResetLast !Set to last in a Range
CLEAR(%FilePre:RECORD,1)
#INSERT(%RestoreRangeFields)
SET(%PrimaryKey,%PrimaryKey) #<! SET to the closest match
#EMBED('Set to Last Record')
#ENDIF
#IF(%HotBar OR %First)
OF ProcessSelected !Process highlighted record
#INSERT(%GetSecondaryRecords)
#FOR(%Formula)
#IF(UPPER(%FormulaClass) <> 'FILTER')
#INSERT(%GenerateFormula)
#ENDIF
#ENDFOR
#EMBED('Process Selected Record')
#IF(%First AND %Last)
DISPLAY(?%First,?%Last) #<! Display the hot fields
#ELSIF(%First)
DISPLAY(?%First) #<! Display the hot fields
#ENDIF
#ENDIF
END ! End CASE
END !End LOOP
EndBrowse !End the browse session
FREE(Queue) !Free the Queue memory
#INSERT(%CloseOpenedFiles)
#EMBED('End of Procedure')
#IF(%UpdateProc)
UpdateProcedure ROUTINE
#EMBED('Prior to Update Procedure')
%UpdateProc
#EMBED('After Update Procedure')
#ENDIF
#PROCEDURE(Validate,'Lookup invalid field value from a file'),SCREEN,PULLDOWN
#!------------------------------------------------------------------------------
#!
#! The Validate Template
#!
#! A Validate procedure must be called as an Edit Procedure
#!
#!------------------------------------------------------------------------------
#MAP('BROWSE.INC')
#PROJECT('%clapfx%BROWS.LIB')
#PROTOTYPE('')
#!
#PROMPT('Range &Limit Field',COMPONENT),%KeyRangeField
#PROMPT('Range &Value Field',FIELD),%RangeValue
#PROMPT('Record Filter',@S180),%RecordFilter
#PROMPT('Lookup Field',COMPONENT),%LookupField
#PROMPT('Input Field Picture',@S30),%LookupPicture
#PROMPT('Locator Field',COMPONENT),%Locator
#PROMPT('Display Key',KEY),%DisplayKey
#PROMPT('Upd&ate Procedure',PROCEDURE),%UpdateProc
#PROMPT('First &Hot Field',FIELD),%First
#PROMPT('Last &Hot Field',FIELD),%Last
#PROMPT('Enable Hot Records',CHECK),%HotBar
#PROMPT('Lookup Hot Key',KEYCODE),%LookupHotKey
#!
#INSERT(%SetBrowseSymbols)
#INSERT(%BrowseErrorCheck)
#IF(%LookupField = %Null)
#SET(%ErrorMessage, (%Procedure & ' ERROR: Lookup Field is required.'))
#ERROR(%ErrorMessage)
#ENDIF
#!
#FIX(%File,%Primary)
#SET(%LookupKey,%PrimaryKey)
#FIX(%Field,%LookupField)
#!
#IF(%FieldType='STRING' OR %FieldType='CSTRING' OR %FieldType='PSTRING')
#SET(%LookupType,'STRING')
#ENDIF
#IF(%DisplayKey = %Null)
#SET(%DisplayKey,%PrimaryKey)
#ENDIF
#INSERT(%StandardHeader)
%Procedure PROCEDURE
#FIX(%ScreenField,'?List')
Queue QUEUE
STRING(%ScreenFieldQueueSize)
END
#IF(%KeyRangeField)
#FIX(%Key,%PrimaryKey)
#SET(%Found, %Null)
#FOR(%KeyField)
#IF(%Found <> 'Yes')
SAV::%KeyField Like(%KeyField)
#ENDIF
#IF(%KeyField = %KeyRangeField)
#SET(%Found, 'Yes')
#ENDIF
#ENDFOR
#ENDIF
#IF(%LookupPicture)
DeformatString STRING(80)
#ENDIF
ButtonIsDisabled BYTE !Flag to allow button enable
#INSERT(%CloseFilesFlags)
%LocalData
%ScreenStructure
%PulldownStructure
#EMBED('Data Section')
CODE
#EMBED('Setup Procedure')
#INSERT(%OpenPrimary)
#EMBED('Before Validate Lookup')
#IF(%LookupHotKey)
IF KEYCODE() <> %LookupHotKey #<!If not requested by hot key
#INSERT(%LookupRecord)
END !End IF
#ELSE
#INSERT(%LookupRecord)
#ENDIF
#INSERT(%OpenSecondaryFiles)
OPEN(Screen) !Open the screen
#EMBED('Setup Screen')
DISPLAY !Display screen fields
#IF(%Pulldown) #!If a Pulldown exists
OPEN(%Pulldown) #<!Open the Pulldown
#ENDIF
#INSERT(%AddFixedListLines)
#INSERT(%BeginBrowse)
LOOP !Process browse requests
CASE BrowseAction(%Primary,%DisplayKey,Queue)#<!Browse the file
OF FormatQueue !Format a queue element
#INSERT(%GetSecondaryRecords)
#FOR(%Formula)
#IF(UPPER(%FormulaClass) = 'LIST')
#INSERT(%Generateformula)
#ENDIF
#ENDFOR
#EMBED('LIST Class formula')
#FIX(%ScreenField,'?List')
Queue = %ScreenFieldExpression !Format the queue line
OF ProcessField !Process a field
#FOR(%Formula)
#IF(UPPER(%FormulaClass) <> 'LIST') #!
#INSERT(%GenerateFormula) #! Generate Formulas
#ENDIF
#ENDFOR
#EMBED('End of General Formulas')
#IF(%HotkeyExists)
CASE KEYCODE()
#FOR(%HotKey)
OF %HotKey !User defined HotKey
%HotKeyProc !HotKey Procedure
#ENDFOR
END
#ENDIF
IF SELECTED() <> FIELD() ! If a new field is selected
CASE SELECTED() ! Jump to setup routine
#IF(%KeyRangeField)
OF ?List
#INSERT(%SaveRangeFields)
#ENDIF
#INSERT(%ScreenSetupRoutines)
END ! End CASE SELECTED()
END ! End IF
CASE FIELD() !Jump to edit routine
#FOR(%ScreenField)
#IF(%ScreenField = '?List')
OF ?List !Process the list field
CASE KEYCODE() !Jump to keycode routine
#IF(%UpdateProc)
#IF(%NoButtonsExist OR %InsertExists)
OF InsKey !For the insert key
#INSERT(%ClearFileFields)
Do UpdateProcedure ! Call the update procedure
#ELSIF(%ChangeExists <> 'YES')
OF InsKey !For the insert key
#INSERT(%ClearFileFields)
Do UpdateProcedure ! Call the update procedure
#ENDIF
#IF(%ChangeExists)
OF CtrlEnter !Or the Ctrl-Enter key
Do UpdateProcedure ! Call the update procedure
#ELSIF(%InsertExists <> 'YES')
OF CtrlEnter !Or the Ctrl-Enter key
Do UpdateProcedure ! Call the update procedure
#ENDIF
#ENDIF
OF MouseLeft2 !On mouse double click
OROF EnterKey !or the enter key
SELECT(?Select) ! Select the Select button
PRESS(EnterKey) ! And complete it.
END !End CASE
#ELSIF(%ScreenField = '?Insert')
#IF(%UpdateProc)
OF ?Insert !Process the Insert Button
#IF(%ScreenFieldEdit)
%ScreenFieldEdit #<!Insert button Edit Routine
#ENDIF
#INSERT(%ClearFileFields)
#INSERT(%RestoreRangeFields)
SETKEYCODE(InsKey) !Set action to Insert
Do UpdateProcedure ! Call the update procedure
SELECT(?List) !Reselect the List field
#ENDIF
#ELSIF(%ScreenField = '?Change')
#IF(%UpdateProc)
OF ?Change !Process the Change Button
#IF(%ScreenFieldEdit)
%ScreenFieldEdit #<!Change button Edit Routine
#ENDIF
SETKEYCODE(EnterKey) !Set action to Change
Do UpdateProcedure ! Call the update procedure
SELECT(?List) !Reselect the List field
#ENDIF
#ELSIF(%ScreenField = '?Select')
OF ?Select !Process the Select button
#IF(%ScreenFieldEdit)
%ScreenFieldEdit #<!Select button Edit Routine
#ENDIF
#IF(%Pulldown) #!If a Pulldown exists
CLOSE(%Pulldown) #<!Close the Pulldown
#ENDIF
CLOSE(Screen) !Close the screen
SELECT(?) !Select the same field
ERASE(?) !Erase the bad value
#IF(%LookupPicture)
PRESS(CLIP(LEFT(FORMAT(%LookupField,%LookupPicture)))) #<! Type in the field value
#ELSIF(%LookupType = 'STRING')
PRESS(CLIP(LEFT(%LookupField))) #<!Type in the field value
#ELSE
PRESS(CLIP(LEFT(FORMAT(%LookupField,@N15))))#<!Type in the field value
#ENDIF
PRESS(TabKey) ! and a tab key
BREAK !Return to caller
#ELSIF(%ScreenFieldEdit)
OF %ScreenField #<! Completed %ScreenField
%ScreenFieldEdit #<! %ScreenField edit routine
#ENDIF
#ENDFOR
#INSERT(%PulldownEditRoutines)
END !End CASE FIELD()
OF NoRecords !No records to browse
#INSERT(%ClearFileFields)
#INSERT(%RestoreRangeFields)
DISPLAY
IF RECORDS(%Primary) #<!If file is not empty
IF ?List <> %FirstEntryField #<! And list is not first
SELECT(%FirstEntryField) #<! Select the first field
ELSE ! From the first field
#IF(%UpdateProc)
#IF(%InsertExists)
SELECT(?Insert) ! Select the Insert Button
#ELSE
#INSERT(%RestoreRangeFields)
SETKEYCODE(InsKey) ! Ask for a new record
DO UpdateProcedure ! Call the update procedure
IF POSITION(%PrimaryKey) = '' #<! If record not added
BREAK ! Return to caller
END ! End IF
IF POSITION(%PrimaryKey) = '' #<! If record not added
BREAK ! Return to caller
END ! End IF
#ENDIF
#ELSE
BREAK ! Return to caller
#ENDIF
END ! End IF
ELSE !If file is empty
#IF(%UpdateProc)
#INSERT(%ClearFileFields)
#INSERT(%RestoreRangeFields)
SETKEYCODE(InsKey) ! Ask for a new record
Do UpdateProcedure ! Call the update procedure
IF RECORDS(%Primary) = 0 #<! If a record was not added
BREAK
END ! End IF
#ELSE
BREAK ! Return to caller
#ENDIF
END !End IF
#IF(%FilterExists OR %KeyRangeField)
OF FilterRecord !Should we add this record
IF ButtonIsDisabled
#IF(%ChangeExists)
ENABLE(?Change) ! Enable the change button
#ENDIF
#IF(%DeleteExists)
ENABLE(?Delete) ! Enable the delete button
#ENDIF
ButtonIsDisabled = FALSE
END
#IF(%KeyRangeField) #!If using range limits
#IF(%RangeValue) #! If using range value field
IF (%KeyRangeField <> %RangeValue) #<! If range field has changed
PREVIOUS(%Primary) #<! Signal browse to build
#INSERT(%ClearFileFields) #! Clear for screen fields
CYCLE ! Cycle for BrowseAction
END ! End IF
#ELSE
#SET(%Found, %Null)
#FOR(%KeyField)
#IF(%Found <> 'Yes')
IF (%KeyField <> SAV::%KeyField) #<! If range field has changed
PREVIOUS(%Primary) #<! Signal browse to build
#INSERT(%ClearFileFields) #! Clear for screen fields
CYCLE ! Cycle for BrowseAction
END ! End IF
#ENDIF
#IF(%KeyField = %KeyRangeField)
#SET(%Found, 'Yes')
#ENDIF
#ENDFOR
#ENDIF
#ENDIF
#IF(%RecordFilter)
IF ~(%RecordFilter) #<!If Filter condition not met
GET(%Primary,0) #<! Dereference the record
CYCLE ! Return to Top of LOOP
END !End IF
#ELSE
#FOR(%Formula)
#IF(UPPER(%FormulaClass) = 'FILTER')
#IF(%FormulaType <> 'COMPUTED')
IF ~(%FormulaCondition) #<!If Filter condition not met
GET(%Primary,0) #<! Dereference the record
CYCLE ! Return to Top of LOOP
END !End IF
#ELSE
IF ~(%FormulaComputation) #<!If Filter condition not met
GET(%Primary,0) #<! Dereference the record
CYCLE ! Return to Top of LOOP
END !End IF
#ENDIF
#ENDIF
#ENDFOR
#ENDIF
#EMBED('After Filter and Range Check')
#ENDIF
#IF(%KeyRangeField)
OF ResetFirst !Set to first in a Range
CLEAR(%FilePre:RECORD,-1)
#INSERT(%RestoreRangeFields)
SET(%PrimaryKey,%PrimaryKey) #<! SET to the closest match
#EMBED('Set to First Record')
OF ResetLast !Set to last in a Range
CLEAR(%FilePre:RECORD,1)
#INSERT(%RestoreRangeFields)
SET(%PrimaryKey,%PrimaryKey) #<! SET to the closest match
#EMBED('Set to Last Record')
#ENDIF
#IF(%HotBar OR %First)
OF ProcessSelected !Process highlighted record
#INSERT(%GetSecondaryRecords)
#FOR(%Formula)
#IF(UPPER(%FormulaClass) <> 'FILTER')
#INSERT(%GenerateFormula)
#ENDIF
#ENDFOR
#EMBED('Process Selected Record')
#IF(%First AND %Last)
DISPLAY(?%First,?%Last) #<! Display the hot fields
#ELSIF(%First)
DISPLAY(?%First) #<! Display the hot fields
#ENDIF
#ENDIF
END !End CASE
END !End LOOP
EndBrowse !End the browse session
FREE(Queue) !Free the Queue memory
#IF(%Pulldown) #!If a Pulldown exists
CLOSE(%Pulldown) #<!Close the Pulldown
#ENDIF
#INSERT(%CloseOpenedFiles)
#EMBED('End of Procedure')
#IF(%UpdateProc)
UpdateProcedure ROUTINE
#EMBED('Prior to Update Procedure')
%UpdateProc
#EMBED('After Update Procedure')
#ENDIF
#!
#PROCEDURE(List,'Scroll all selected records from a file'),SCREEN,PULLDOWN
#!------------------------------------------------------------------------------
#!
#! The List Template
#!
#! The List template loads the entire set of selected records into
#! a memory queue for displaying with a list box structure.
#!
#! Since the entire queue is filled at load time, this template should
#! not be used with very large files as they may overflow the primary
#! virtual memory area and spill over to disk. The result would be
#! a listbox which works very slow and accesses the hard disk drive when
#! scrolling.
#!
#! A checkbox is available to view a file in Record order. This is
#! primarily useful in viewing ASCII, DOS, or BASIC files.
#! (The View template may also be used.)
#!
#! If the Record Order checkbox is on, any reference to the
#! PrimaryKey is ignored. Deletes, and Updates may not be allowed
#! with certain non-keyed data file types.
#!
#! Also, a checkbox is available to display the queue in reverse
#! order. If both the Record Order checkbox, and the Reverse Order
#! checkbox are on then the file will be displayed in Reverse record
#! order. If Just the Reverse Order checkbox is on, the file
#! will be displayed in Reverse key order.
#!
#! Use with an Update Procedure:
#!
#! Since a Form template allows the multiple add ability, and
#! since a List procedure may be used on a network, a checkbox
#! has been added to control the rebuilding of the queue upon
#! return from the Update Procedure. When checked, the queue
#! will always be rebuilt to accomodate any updates made by other
#! network file users, or multiple record adds by another procedure.
#!
#!------------------------------------------------------------------------------
#PROMPT('Range &Limit Field',COMPONENT),%KeyRangeField
#PROMPT('Range &Value Field',FIELD),%RangeValue
#PROMPT('Record Filter',@S180),%RecordFilter
#PROMPT('Upd&ate Procedure',PROCEDURE),%UpdateProc
#PROMPT('First &Hot Field',FIELD),%First
#PROMPT('Last &Hot Field',FIELD),%Last
#PROMPT('Enable Hot Records',CHECK),%HotBar
#PROMPT('&Queue Rebuild',CHECK),%QueueRebuild
#PROMPT('Record Order',CHECK),%RecordOrder
#PROMPT('Reverse Order',CHECK),%ReverseOrder
#PROMPT('Progress &Indicator',CHECK),%ShowProg
#PROMPT('Progress &Character',@S8),%ProgChar
#PROTOTYPE('')
#INSERT(%StandardHeader)
#INSERT(%SetBrowseSymbols)
%Procedure PROCEDURE
Queue QUEUE !Listbox Queue contains
FilePointer Ulong
#FIX(%File,%Primary)
#FIX(%Key,%PrimaryKey)
#SET(%FirstField, %Null)
#FOR(%KeyField)
QUE::%KeyField LIKE(%KeyField) #<! And Key element(s) for sort
#IF(%FirstField = %Null)
#SET(%FirstField, %KeyField)
#SET(%FirstFieldSequence, %KeyFieldSequence)
#ENDIF
#IF(%RecordOrder = %Null)
#IF(%KeyFieldSequence <> 'DESCENDING' AND %ReverseOrder = %Null)
#SET(%SortString, (CLIP(LEFT(%SortString)) & ',+QUE::' & %KeyField))
#ELSE
#SET(%SortString, (CLIP(LEFT(%SortString)) & ',-QUE::' & %KeyField))
#ENDIF
#ENDIF
#ENDFOR
#IF((%RecordOrder AND %ReverseOrder))
#SET(%SortString,(','& %FixRows+1))
#ENDIF
#FIX(%ScreenField,'?LIST')
Line STRING(%ScreenFieldQueueSize) #<! Line to be scrolled
.
#IF(%KeyRangeField)
#FIX(%Key,%PrimaryKey)
#SET(%Found, %Null)
#FOR(%KeyField)
#IF(%Found <> 'Yes')
SAV::%KeyField Like(%KeyField)
#ENDIF
#IF(%KeyField = %KeyRangeField)
#SET(%Found, 'Yes')
#ENDIF
#ENDFOR
#ENDIF
ButtonIsDisabled BYTE !Flag to allow button enable
#INSERT(%CloseFilesFlags)
%LocalData
%ScreenStructure
%PulldownStructure
#EMBED('Data Section')
PreUpdateCount ULONG !Records in file count.
FirstPage BYTE !First page flag
#IF(%ShowProg)
VEW::Length BYTE ! Progress variable
VEW::ProgString STRING('<176>{80}') ! Progress display variable
#ENDIF
CODE
#EMBED('Setup Procedure')
#INSERT(%OpenPrimary)
#INSERT(%OpenSecondaryFiles)
OPEN(Screen) !Open the screen
#EMBED('Setup Screen')
DISPLAY !Display screen fields
#INSERT(%BuildListIndex)
IF ?LIST = %FirstEntryField #<!If no entry for ranges
DO FillQueue ! Fill the QUEUE
IF RECORDS(Queue) = %FixRows #<! If no QUEUE records
#IF(%InsertExists)
SELECT(?Insert) ! Select the Insert button
#ELSIF(%UpdateProc)
#INSERT(%RestoreRangeFields)
SETKEYCODE(InsKey) ! Set action to Insert
Do UpdateProcedure ! Call the update procedure
DO FillQueue ! Fill the QUEUE
IF RECORDS(Queue) = %FixRows #<! If still no records
FREE(Queue) ! Free the QUEUE
#INSERT(%CloseOpenedFiles)
RETURN ! Return to the caller
END ! End IF
#ELSE
FREE(Queue) ! Free the QUEUE
#INSERT(%CloseOpenedFiles)
RETURN ! Return to the caller
#ENDIF
END ! End IF
END !End IF
LOOP !Screen handling loop
#FOR(%Formula)
#IF(UPPER(%FormulaClass) <> 'LIST')
#IF(UPPER(%FormulaClass) <> 'FILTER')
#INSERT(%GenerateFormula)
#ENDIF
#ENDIF
#ENDFOR
#EMBED('End of General Formulas')
CASE SELECTED() !Jump to field setup routine
#INSERT(%ScreenSetupRoutines)
END !End CASE
ACCEPT !Enable the keyboard
CASE KEYCODE() !Jump to hotkey procedures
#FOR(%HotKey)
OF %HotKey !User defined HotKey
%HotKeyProc !HotKey Procedure
#ENDFOR
END !End CASE
IF REFER() AND SELECTED() = ?List | !If list field is selected
AND FIELD() < ?List ! From a prior changed field
DO FillQueue ! Fill the QUEUE
END !End IF
CASE FIELD() !Jump to edit routine
#FOR(%ScreenField)
#IF(%ScreenField = '?Insert')
#IF(%UpdateProc)
OF ?Insert !Process the Insert Button
#IF(%ScreenFieldEdit)
%ScreenFieldEdit #<! Insert button Edit Routine
#ENDIF
GET(%Primary,0) #<! Dereference current record
#INSERT(%ClearFileFields)
#INSERT(%RestoreRangeFields)
PreUpdateCount = Records(%Primary) #<! Save a record count
SETKEYCODE(InsKey) ! Set action to Insert
Do UpdateProcedure ! Call the update procedure
#IF(%QueueRebuild)
Do FillQueue ! Fill the QUEUE
#ELSE
CASE RECORDS(%Primary) #<! Check the record count
OF PreUpdateCount ! If no change
SELECT(?List) ! Reselect the list box
OF PreUpdateCount + 1 ! If 1 record added
#FIX(%ScreenField,'?List')
Line = %ScreenFieldExpression #<! Fill the QUEUE line
FilePointer = POINTER(%Primary) #<! Save the file pointer
#INSERT(%FillKeyValues)
ADD(Queue %SortString) #<! Add the record sorted
ELSE ! Otherwise
Do FillQueue ! Rebuild the QUEUE
END ! End CASE
#ENDIF
SELECT(?List) ! Reselect the List field
#ENDIF
#ENDIF
#IF(%ScreenField = '?Change')
#IF(%UpdateProc)
OF ?Change !Process the Change Button
#IF(%ScreenFieldEdit)
%ScreenFieldEdit #<! Change button Edit Routine
#ENDIF
GET(Queue,CHOICE(?List)) !Get the QUEUE element
GET(%Primary,FilePointer) #<!Get the record
SETKEYCODE(EnterKey) ! Set action to Change
Do UpdateProcedure ! Call the update procedure
#IF(%QueueRebuild)
Do FillQueue ! Fill the QUEUE
#ENDIF
SELECT(?List) ! Reselect the List field
#ENDIF
#ENDIF
#IF(%ScreenField = '?Delete')
#IF(%UpdateProc)
OF ?Delete !Process the Delete Button
#IF(%ScreenFieldEdit)
%ScreenFieldEdit #<! Delete button Edit Routine
#ENDIF
GET(Queue,CHOICE(?List)) ! Get the QUEUE element
GET(%Primary,FilePointer) #<! Get the record
SETKEYCODE(DelKey) ! Set action to Delete
Do UpdateProcedure ! Call the update procedure
#IF(%QueueRebuild)
Do FillQueue ! Fill the QUEUE
#ENDIF
SELECT(?List) ! Reselect the List field
#ENDIF
#ENDIF
#IF(%ScreenField = '?List')
OF ?List !Process the list field
#IF(%HotBar OR %First)
GET(Queue,CHOICE(?List)) ! Get the QUEUE element
GET(%Primary,FilePointer) #<! Get the record
#ENDIF
#IF(%ScreenFieldEdit)
%ScreenFieldEdit #<! Exit button Edit Routine
#ENDIF
#IF(%First AND %Last)
DISPLAY(?%First,?%Last) #<! Display the hot fields
#ELSIF(%First)
DISPLAY(?%First) #<! Display the hot fields
#ENDIF
#IF(%UpdateProc)
CASE KEYCODE() ! Jump to keycode routine
#IF(%NoButtonsExist OR %InsertExists)
OF InsKey ! For the insert key
GET(%Primary,0) #<! Dereference current record
#INSERT(%ClearFileFields)
Do UpdateProcedure ! Call the update procedure
#IF(%QueueRebuild)
Do FillQueue ! Fill the QUEUE
#ENDIF
#ENDIF
#IF(%NoButtonsExist OR %DeleteExists)
OF DelKey ! For the delete key
PreUpdateCount = Records(%Primary) ! Save a record count
GET(Queue,CHOICE(?List)) ! Get the QUEUE element
GET(%Primary,FilePointer) #<! Get the record
Do UpdateProcedure ! Call the update procedure
#IF(%QueueRebuild)
Do FillQueue ! Fill the QUEUE
#ELSE
IF RECORDS(%Primary) = PreUpdateCount -1 #<! If the record was deleted
DELETE(Queue) ! Delete the Queue entry
END ! End IF
#ENDIF
#ENDIF
#IF(%NoButtonsExist OR %ChangeExists )
OF EnterKey ! Or the enter key
OROF MouseLeft2 ! Or a double mouse click
GET(Queue,CHOICE(?List)) ! Get the QUEUE element
GET(%Primary,FilePointer) #<! Get the record
Do UpdateProcedure ! Call the update procedure
#IF(%QueueRebuild)
Do FillQueue ! Fill the QUEUE
#ENDIF
#ENDIF
END ! End CASE keycode
#ENDIF
#ELSIF(%ScreenField = '?Exit')
OF ?Exit !Process the Exit button
#IF(%ScreenFieldEdit)
%ScreenFieldEdit #<! Exit button Edit Routine
#ENDIF
BREAK ! Return to caller
#ELSIF(%ScreenFieldEdit)
OF %ScreenField #<! Completed %ScreenField
%ScreenFieldEdit #<! %ScreenField edit routine
#ENDIF
#ENDFOR
#INSERT(%PulldownEditRoutines)
END !End CASE FIELD()
DISPLAY
END !End LOOP
FREE(Queue) !Free the QUEUE
#IF(%Pulldown) #!If a Pulldown exists
CLOSE(%Pulldown) #<!Close the Pulldown
#ENDIF
#INSERT(%CloseOpenedFiles)
#EMBED('End of Procedure')
FillQueue Routine
#EMBED('Start of Fill Queue Routine')
FREE(Queue) #<!Clear the QUEUE
Firstpage = 1 !Set the FirstPage flag
#IF(%ShowProg) #!If showing the progress
VEW::Length = 1 !Set the status bar counter
#ENDIF
#FIX(%ScreenField,'?List')
#FOR(%ScreenFieldFix)
Line = %ScreenFieldFix #<!Add list box fields
#IF(%RecordOrder = %Null)
#IF(%FirstFieldSequence <> 'DESCENDING' AND %ReverseOrder = %Null)
CLEAR(QUE::%FirstField) #<!Clear the key field
#ELSE
CLEAR(QUE::%FirstField,1) #<!Clear the key field
#ENDIF
#ENDIF
ADD(Queue) !Add the fixed line
DISPLAY(?List) #<!Blank the listbox
#ENDFOR
#IF(%RecordOrder)
SET(%Primary) #<!Set to file order
#ELSIF(%KeyRangeField)
#IF(%ReverseOrder)
CLEAR(%FilePre:RECORD,1) #<!Clear to highest value
#ELSE
CLEAR(%FilePre:RECORD) #<!Clear to lowest value
#ENDIF
%KeyRangeField = %RangeValue #<!Fill range field
SET(%PrimaryKey,%PrimaryKey) #<!Set to keyed order
#ELSE
SET(%PrimaryKey) #<!Set to keyed order
#ENDIF
#IF(%ShowProg) #!If showing the progress
VEW::ProgString = ALL(%ProgChar) #<!Fill the progress string
#ENDIF
LOOP !Get all selected records
#IF(%RecordOrder)
NEXT(%Primary) #<! Get the next record.
#ELSIF(%ReverseOrder)
PREVIOUS(%Primary) #<! Get the previous record
#ELSE
NEXT(%Primary) #<! Get the next record.
#ENDIF
IF ERRORCODE() THEN BREAK. ! Quit if an error occurs
#INSERT(%GetSecondaryRecords)
#FIX(%File,%Primary)
#FIX(%Key,%PrimaryKey)
#IF(%KeyRangeField) #!If using a Range
IF %KeyRangeField <> %RangeValue #<! If not in Range
BREAK #<! Break out of the Loop
END ! End IF
#ENDIF
#IF(%RecordFilter)
IF ~(%RecordFilter) #<! If Filter condition not met
CYCLE ! Try another record
END ! End IF
#ELSE
#FOR(%Formula)
#IF(UPPER(%FormulaClass) = 'FILTER')
#IF(%FormulaType <> 'COMPUTED')
IF ~(%FormulaCondition) #<! If Filter condition not met
CYCLE ! Try another record
END ! End IF
#ELSE
IF ~(%FormulaComputation) #<! If Filter condition not met
CYCLE ! Try another record
END ! End IF
#ENDIF
#ENDIF
#ENDFOR
#ENDIF
#FOR(%Formula)
#IF(UPPER(%FormulaClass) = 'LIST')
#INSERT(%GenerateFormula)
#ENDIF
#ENDFOR
#EMBED('LIST Class formula')
#IF(%ShowProg) #!If showing the progress
#INSERT(%ShowFileProgress) #!Insert the progress code
#ENDIF
#FIX(%ScreenField,'?LIST')
Line = %ScreenFieldExpression #<! Fill the QUEUE line
FilePointer = POINTER(%Primary) #<! Fill the file pointer
#FOR(%KeyField)
QUE::%KeyField =%KeyField #<! Fill the key field
#ENDFOR
ADD(Queue %SortString) #<! Add to the QUEUE
IF ERRORCODE() THEN BREAK. ! Quit out if error
IF FirstPage ! If page 1
IF RECORDS(Queue) = ROWS(?List) ! If we have a full screen
FirstPage = 0 ! turn off the page flag
END ! End IF
DISPLAY(?List) ! Display page 1
END ! End IF
LOOP WHILE KEYBOARD() ! While Keyboard Input
SELECT(?List) ! Select the List box
ACCEPT ! Accept a Key
IF KEYCODE() = EscKey ! If the Escape key
FREE(Queue) ! Free the QUEUE
#INSERT(%CloseOpenedFiles)
RETURN ! Return to caller
END ! End IF
DISPLAY(?List) ! Redisplay the list box
END ! End LOOP
END !End LOOP
#IF(%ShowProg) #!If showing the progress
ERASE(?StatusLine) !Clear the StatusLine
#ENDIF
DISPLAY !Redisplay the screen
#IF(%UpdateProc)
UpdateProcedure ROUTINE
#EMBED('Prior to Update Procedure')
%UpdateProc
#EMBED('After Update Procedure')
#ENDIF
#!
#PROCEDURE(Select,'Select a record from a file'),SCREEN,PULLDOWN
#!------------------------------------------------------------------------------
#!
#! The Select Template
#!
#! Select a record from a file into memory
#!
#!------------------------------------------------------------------------------
#MAP('BROWSE.INC')
#PROJECT('%clapfx%BROWS.LIB')
#PROTOTYPE('')
#!
#PROMPT('Range &Limit Field',COMPONENT),%KeyRangeField
#PROMPT('Range &Value Field',FIELD),%RangeValue
#PROMPT('Record Filter',@S180),%RecordFilter
#PROMPT('Locator Field',COMPONENT),%Locator
#PROMPT('Upd&ate Procedure',PROCEDURE),%UpdateProc
#PROMPT('First &Hot Field',FIELD),%First
#PROMPT('Last &Hot Field',FIELD),%Last
#PROMPT('Enable Hot Records',CHECK),%HotBar
#!
#INSERT(%SetBrowseSymbols)
#INSERT(%BrowseErrorCheck)
#INSERT(%StandardHeader)
%Procedure PROCEDURE
#FIX(%ScreenField,'?List')
Queue QUEUE
STRING(%ScreenFieldQueueSize)
END
#IF(%KeyRangeField)
#FIX(%Key,%PrimaryKey)
#SET(%Found, %Null)
#FOR(%KeyField)
#IF(%Found <> 'Yes')
SAV::%KeyField Like(%KeyField)
#ENDIF
#IF(%KeyField = %KeyRangeField)
#SET(%Found, 'Yes')
#ENDIF
#ENDFOR
#ENDIF
ButtonIsDisabled BYTE !Flag to allow button enable
#INSERT(%CloseFilesFlags)
%LocalData
%ScreenStructure
%PulldownStructure
#EMBED('Data Section')
CODE
#EMBED('Setup Procedure')
#INSERT(%OpenPrimary)
#INSERT(%OpenSecondaryFiles)
OPEN(Screen) !Open the screen
#EMBED('Setup Screen')
DISPLAY !Display screen fields
#INSERT(%SaveRangeFields)
#IF(%Pulldown) #!If a Pulldown exists
OPEN(%Pulldown) #<!Open the Pulldown
#ENDIF
#INSERT(%AddFixedListLines)
#INSERT(%BeginBrowse)
LOOP !Process browse requests
CASE BrowseAction(%Primary,%PrimaryKey,Queue)#<!Browse the file
OF FormatQueue !Format a QUEUE element
#INSERT(%GetSecondaryRecords)
#FOR(%Formula)
#IF(UPPER(%FormulaClass) = 'LIST')
#INSERT(%Generateformula)
#ENDIF
#ENDFOR
#EMBED('LIST Class formula')
#FIX(%ScreenField,'?List')
Queue = %ScreenFieldExpression !Format the QUEUE line
OF ProcessField !Process a field
#FOR(%Formula)
#IF(UPPER(%FormulaClass) <> 'LIST') #!
#INSERT(%GenerateFormula) #! Generate Formulas
#ENDIF
#ENDFOR
#EMBED('End of General Formulas')
#IF(%HotKeyExists)
CASE KEYCODE()
#FOR(%HotKey)
OF %HotKey #<!User defined HotKey
%HotKeyProc #<!HotKey Procedure
#ENDFOR
END
#ENDIF
IF SELECTED() <> FIELD() ! If a new field is selected
CASE SELECTED() ! Jump to setup routine
#IF(%KeyRangeField)
OF ?List
#INSERT(%SaveRangeFields)
#ENDIF
#INSERT(%ScreenSetupRoutines)
END ! End CASE SELECTED()
END ! End IF
CASE FIELD() !Jump to edit routine
#FOR(%ScreenField)
#IF(%ScreenField = '?List')
OF ?List !Process the list field
CASE KEYCODE() !Jump to keycode routine
#IF(%UpdateProc)
#IF(%NoButtonsExist OR %InsertExists)
OF InsKey !For the insert key
#INSERT(%ClearFileFields)
Do UpdateProcedure ! Call the update procedure
#ELSIF(%ChangeExists <> 'YES')
OF InsKey !For the insert key
#INSERT(%ClearFileFields)
Do UpdateProcedure ! Call the update procedure
#ENDIF
#IF(%ChangeExists)
OF CtrlEnter !Or the Ctrl-Enter key
Do UpdateProcedure ! Call the update procedure
#ELSIF(%InsertExists <> 'YES')
OF CtrlEnter !Or the Ctrl-Enter key
Do UpdateProcedure ! Call the update procedure
#ENDIF
#ENDIF
OF MouseLeft2 !On mouse double click
OROF EnterKey !or the enter key
SELECT(?Select) ! Select the Select button
PRESS(EnterKey) ! And complete it.
END !End CASE
#ELSIF(%ScreenField = '?Insert')
#IF(%UpdateProc)
OF ?Insert !Process the Insert Button
#IF(%ScreenFieldEdit)
%ScreenFieldEdit #<!Insert button Edit Routine
#ENDIF
#INSERT(%ClearFileFields)
#INSERT(%RestoreRangeFields)
SETKEYCODE(InsKey) !Set action to Insert
Do UpdateProcedure ! Call the update procedure
SELECT(?List) !Reselect the List field
#ENDIF
#ELSIF(%ScreenField = '?Change')
#IF(%UpdateProc)
OF ?Change !Process the Change Button
#IF(%ScreenFieldEdit)
%ScreenFieldEdit #<!Change button Edit Routine
#ENDIF
SETKEYCODE(EnterKey) !Set action to Change
Do UpdateProcedure ! Call the update procedure
SELECT(?List) !Reselect the List field
#ENDIF
#ELSIF(%ScreenField = '?Select')
OF ?Select !Process the Select button
#IF(%ScreenFieldEdit)
%ScreenFieldEdit #<!Select button Edit Routine
#ENDIF
BREAK
#ELSIF(%ScreenField = '?Cancel')
OF ?Cancel !Process the Select button
#IF(%ScreenFieldEdit)
%ScreenFieldEdit #<!Select button Edit Routine
#ENDIF
#INSERT(%ClearFileFields)
BREAK
#ELSIF(%ScreenFieldEdit)
OF %ScreenField #<! Completed %ScreenField
%ScreenFieldEdit #<! %ScreenField edit routine
#ENDIF
#ENDFOR
#INSERT(%PulldownEditRoutines)
END !End CASE FIELD()
OF NoRecords !No records to browse
#INSERT(%ClearFileFields)
#INSERT(%RestoreRangeFields)
DISPLAY
#IF(%ChangeExists)
DISABLE(?Change) ! Disable the change button
#ENDIF
#IF(%DeleteExists)
DISABLE(?Delete) ! Disable the delete button
#ENDIF
ButtonIsDisabled = TRUE
IF RECORDS(%Primary) #<! If file is not empty
IF ?List <> %FirstEntryField #<! And list is not first
SELECT(%FirstEntryField) #<! Select the first field
ELSE ! Else
#IF(%UpdateProc)
#IF(%InsertExists)
SELECT(?Insert) ! Select the Insert Button
#ELSE
#INSERT(%RestoreRangeFields)
SETKEYCODE(InsKey) ! Ask for a new record
DO UpdateProcedure ! Call the update procedure
IF POSITION(%PrimaryKey) = '' #<! If record not added
BREAK ! Return to caller
ELSE ! Else record was added
#IF(%ChangeExists)
ENABLE(?Change) ! Disable the change button
#ENDIF
#IF(%DeleteExists)
ENABLE(?Delete) ! Disable the delete button
#ENDIF
ButtonIsDisabled = FALSE
END ! End IF
#ENDIF
#ELSE
BREAK ! Return to caller
#ENDIF
END ! End IF
ELSE ! Else if file is empty
#IF(%UpdateProc)
#INSERT(%RestoreRangeFields)
SETKEYCODE(InsKey) ! Ask for a new record
DO UpdateProcedure ! Call the update procedure
IF POSITION(%PrimaryKey) = '' #<! If record not added
BREAK ! Return to caller
ELSE ! Else record was added
#IF(%ChangeExists)
ENABLE(?Change) ! Disable the change button
#ENDIF
#IF(%DeleteExists)
ENABLE(?Delete) ! Disable the delete button
#ENDIF
ButtonIsDisabled = FALSE
END ! End IF
#ELSE
BREAK ! Return to caller
#ENDIF
END ! End IF
#IF(%FilterExists OR %KeyRangeField)
OF FilterRecord !Should we add this record
IF ButtonIsDisabled
#IF(%ChangeExists)
ENABLE(?Change) ! Enable the change button
#ENDIF
#IF(%DeleteExists)
ENABLE(?Delete) ! Enable the delete button
#ENDIF
ButtonIsDisabled = FALSE
END
#IF(%KeyRangeField) #!If using range limits
#IF(%RangeValue) #! If using range value field
IF (%KeyRangeField <> %RangeValue) #<! If range field has changed
PREVIOUS(%Primary) #<! Signal browse to build
#INSERT(%ClearFileFields) #! Clear for screen fields
CYCLE ! Cycle for BrowseAction
END ! End IF
#ELSE
#SET(%Found, %Null)
#FOR(%KeyField)
#IF(%Found <> 'Yes')
IF (%KeyField <> SAV::%KeyField) #<! If range field has changed
PREVIOUS(%Primary) #<! Signal browse to build
#INSERT(%ClearFileFields) #! Clear for screen fields
CYCLE ! Cycle for BrowseAction
END ! End IF
#ENDIF
#IF(%KeyField = %KeyRangeField)
#SET(%Found, 'Yes')
#ENDIF
#ENDFOR
#ENDIF
#ENDIF
#IF(%RecordFilter)
IF ~(%RecordFilter) #<!If Filter condition not met
GET(%Primary,0) #<! Dereference the record
CYCLE ! Return to Top of LOOP
END !End IF
#ELSE
#FOR(%Formula)
#IF(UPPER(%FormulaClass) = 'FILTER')
#IF(%FormulaType <> 'COMPUTED')
IF ~(%FormulaCondition) #<!If Filter condition not met
GET(%Primary,0) #<! Dereference the record
CYCLE ! Return to Top of LOOP
END !End IF
#ELSE
IF ~(%FormulaComputation) #<!If Filter condition not met
GET(%Primary,0) #<! Dereference the record
CYCLE ! Return to Top of LOOP
END !End IF
#ENDIF
#ENDIF
#ENDFOR
#ENDIF
#EMBED('After Filter and Range Check')
#ENDIF
#IF(%KeyRangeField)
OF ResetFirst !Set to first in a Range
CLEAR(%FilePre:RECORD,-1)
#INSERT(%RestoreRangeFields)
SET(%PrimaryKey,%PrimaryKey) #<! SET to the closest match
#EMBED('Set to First Record')
OF ResetLast !Set to last in a Range
CLEAR(%FilePre:RECORD,1)
#INSERT(%RestoreRangeFields)
SET(%PrimaryKey,%PrimaryKey) #<! SET to the closest match
#EMBED('Set to Last Record')
#ENDIF
#IF(%HotBar OR %First)
OF ProcessSelected !Process highlighted record
#INSERT(%GetSecondaryRecords)
#FOR(%Formula)
#IF(UPPER(%FormulaClass) <> 'FILTER')
#INSERT(%GenerateFormula)
#ENDIF
#ENDFOR
#EMBED('Process Selected Record')
#IF(%First AND %Last)
DISPLAY(?%First,?%Last) #<! Display the hot fields
#ELSIF(%First)
DISPLAY(?%First) #<! Display the hot fields
#ENDIF
#ENDIF
END !End CASE
END !End LOOP
EndBrowse !End the browse session
FREE(Queue) !Free the Queue memory
#IF(%Pulldown) #!If a Pulldown exists
CLOSE(%Pulldown) #<!Close the Pulldown
#ENDIF
#INSERT(%CloseOpenedFiles)
#EMBED('End of Procedure')
#IF(%UpdateProc)
UpdateProcedure ROUTINE
#EMBED('Prior to Update Procedure')
%UpdateProc
#EMBED('After Update Procedure')
#ENDIF
#!
#!***************************************************************************
#GROUP(%ShowFileProgress)
VEW::Length += 1
StatusLine = ' Reading File: ' & SUB(VEW::ProgString,1,VEW::Length)
IF VEW::Length = LEN(StatusLine) - 15
VEW::Length = 1
StatusLine = ' Reading File: ' & ' {65}'
END
Display(?StatusLine)
#!
#!***************************************************************************
#GROUP(%SetBrowseSymbols)
#SET(%FirstEntryField,%Null)
#SET(%NoButtonsExist,%Null)
#SET(%InsertExists,%Null)
#SET(%ChangeExists,%Null)
#SET(%DeleteExists,%Null)
#SET(%ExitExists,%Null)
#SET(%FileExists,%Null)
#SET(%FilterExists,%Null)
#SET(%HotKeyExists,%Null)
#SET(%ScreenFldSetupExists,%Null)
#SET(%ScreenFldEditExists,%Null)
#FOR(%File)
#SET(%FileExists,'YES')
#BREAK
#ENDFOR
#FIX(%File,%Primary)
#FOR(%HotKey)
#SET(%HotKeyExists,'YES')
#BREAK
#ENDFOR
#FOR(%Formula)
#IF(UPPER(%FormulaClass) = 'FILTER')
#SET(%FilterExists, 'YES')
#ENDIF
#ENDFOR
#IF(%RecordFilter)
#SET(%FilterExists, 'YES')
#ENDIF
#SET(%FirstEntryFound,%Null)
#FOR(%ScreenField)
#SET(%ScreenFieldExists,'YES')
#IF(%FirstEntryFound = %Null)
#SET(%FirstEntryField, (%FirstEntryField + 1))
#IF(%ScreenFieldSkip <> 'Y')
#SET(%FirstEntryFound,'YES')
#ENDIF
#ENDIF
#IF(%ScreenFieldType = 'BUTTON')
#IF(UPPER(%ScreenField) = '?INSERT')
#SET(%InsertExists, 'YES')
#ELSIF(UPPER(%ScreenField) = '?CHANGE')
#SET(%ChangeExists, 'YES')
#ELSIF(UPPER(%ScreenField) = '?DELETE')
#SET(%DeleteExists, 'YES')
#ELSIF(UPPER(%ScreenField) = '?EXIT')
#SET(%ExitExists, 'YES')
#ENDIF
#ENDIF
#IF(%ScreenFieldSetup)
#SET(%ScreenFldSetupExists,'YES')
#ENDIF
#IF(%ScreenFieldEdit)
#SET(%ScreenFldEditExists,'YES')
#ENDIF
#ENDFOR
#IF(%InsertExists=%Null AND %ChangeExists=%Null AND %DeleteExists=%Null)
#SET(%NoButtonsExist, 'YES')
#ENDIF
#SET(%FixRows, '0')
#FIX(%ScreenField,'?List')
#FOR(%ScreenFieldFix)
#SET(%FixRows, (%FixRows + 1))
#ENDFOR
#!
#!***************************************************************************
#GROUP(%LookupRecord) #!Group to Lookup a record
#IF(%FromLookup)
#IF(%LookupPicture)
DeformatString = CONTENTS(SELECTED()) #<! Fill the Key Value
#ELSE
%LookupField = CONTENTS(SELECTED()) #<! Fill the Key Value
#ENDIF
#ELSE
#IF(%LookupPicture)
DeformatString = CONTENTS(FIELD()) #<! Fill the Key Value
#ELSE
%LookupField = CONTENTS(FIELD()) #<! Fill the Key Value
#ENDIF
#ENDIF
#IF(%LookupPicture)
%LookupField = DEFORMAT(DeformatString,%LookupPicture)
#ENDIF
GET(%Primary,%LookupKey) #<! Get the matching record
IF ~ERRORCODE() #<! If found then return
#INSERT(%CloseOpenedFiles)
RETURN
END
#!***************************************************************************
#GROUP(%AddFixedListLines) #!Group to add any QUEUE fixed
#FIX(%ScreenField,'?List') #! lines to the QUEUE.
#FOR(%ScreenFieldFix)
Queue = %ScreenFieldFix #<!Add fixed listbox line
ADD(Queue) ! to the QUEUE
#ENDFOR
#!***************************************************************************
#GROUP(%BeginBrowse)
#IF(%Locator) #!Conditionally initialize
#IF(%HotBar OR %First) #! the browse session manager
BeginBrowse(?List,?%Locator,1) #<!Begin a browse session
#ELSE
BeginBrowse(?List,?%Locator) #<!Begin a browse session
#ENDIF
#ELSE
#IF(%HotBar OR %First)
BeginBrowse(?List,,1) #<!Begin a browse session
#ELSE
BeginBrowse(?List) #<!Begin a browse session
#ENDIF
#ENDIF
#!***************************************************************************
#GROUP(%BrowseEditRoutines)
#FOR(%ScreenField) #! on a screen field
#IF(%ScreenFieldEdit) #! And not on one of the
#IF(UPPER(%ScreenField)<>'?INSERT') #! predefined buttons
#IF(UPPER(%ScreenField)<>'?CHANGE')
#IF(UPPER(%ScreenField)<>'?DELETE')
#IF(UPPER(%ScreenField)<>'?EXIT')
OF %ScreenField #<!Edit Procedure or source
%ScreenFieldEdit #<! for %ScreenField
#ENDIF
#ENDIF
#ENDIF
#ENDIF
#ENDIF
#ENDFOR
#!
#! *******************************************************************
#GROUP(%ListEditRoutines)
#FOR(%ScreenField) #! On a screen field
#IF(%ScreenFieldEdit) #! And not on one of the
#IF(UPPER(%ScreenField)<>'?INSERT') #! predefined buttons
#IF(UPPER(%ScreenField)<>'?CHANGE')
#IF(UPPER(%ScreenField)<>'?DELETE')
OF %ScreenField #<!Edit Procedure or source
%ScreenFieldEdit #<! for %ScreenField
#ENDIF
#ENDIF
#ENDIF
#ENDIF
#ENDFOR
#!
#!***************************************************************************
#GROUP(%FillKeyValues)
#FOR(%KeyField)
QUE::%KeyField =%KeyField #<! Fill any key fields
#ENDFOR
#!
#!***************************************************************************
#GROUP(%BrowseErrorCheck)
#!
#IF(%Primary = %Null)
#SET(%ErrorMessage, (%Procedure & ' ERROR: No file has been chosen for this procedure.'))
#ERROR(%ErrorMessage)
#SET(%ErrorMessage, ' A file must be selected for this procedure.')
#ERROR(%ErrorMessage)
#ENDIF
#IF(%PrimaryKey = %Null)
#SET(%ErrorMessage, (%Procedure & ' ERROR: No Access Key has been chosen for this procedure.'))
#ERROR(%ErrorMessage)
#SET(%ErrorMessage, ' An Access Key must be identified on the File Schematic.')
#ERROR(%ErrorMessage)
#ENDIF
#IF(%KeyRangeField)
#IF(%KeyRangeField = %RangeValue)
#SET(%ErrorMessage, (%Procedure & ' ERROR: Range Limit Field and Range Value fields must'))
#ERROR(%ErrorMessage)
#SET(%ErrorMessage, ' be separate fields.')
#ERROR(%ErrorMessage)
#ENDIF
#ENDIF
#IF(%First)
#SET(%FirstHotEquate, ('?' & %First))
#FIX(%ScreenField,%FirstHotEquate)
#IF(%ScreenField <> %FirstHotEquate)
#SET(%ErrorMessage, (%Procedure & ' ERROR: the First Hot field must be a display'))
#ERROR(%ErrorMessage)
#SET(%ErrorMessage, ' field on the SCREEN. ')
#ERROR(%ErrorMessage)
#ENDIF
#ENDIF
#IF(%Last)
#SET(%LastHotEquate, ('?' & %Last))
#FIX(%ScreenField,%LastHotEquate)
#IF(%ScreenField <> %LastHotEquate)
#SET(%ErrorMessage, (%Procedure & ' ERROR: the Last Hot field must be a display'))
#ERROR(%ErrorMessage)
#SET(%ErrorMessage, ' field on the SCREEN. ')
#ERROR(%ErrorMessage)
#ENDIF
#ENDIF
#FIX(%File,%Primary)
#IF(%DisplayKey)
#FIX(%Key,%DisplayKey)
#ELSE
#FIX(%Key,%PrimaryKey)
#ENDIF
#IF(%Locator)
#SET(%FieldFound,%Null)
#FOR(%KeyField)
#IF(%KeyField = %Locator)
#SET(%FieldFound,'Yes')
#BREAK
#ENDIF
#ENDFOR
#IF(%FieldFound = %Null)
#SET(%ErrorMessage, (%Procedure & ' ERROR: the Locator Field must be a component of'))
#ERROR(%ErrorMessage)
#SET(%ErrorMessage, (' the ' & %Key & ' key.'))
#ERROR(%ErrorMessage)
#ENDIF
#ENDIF
#FIX(%Key,%PrimaryKey)
#IF(%KeyRangeField)
#SET(%FieldFound,%Null)
#FOR(%KeyField)
#IF(%KeyField = %KeyRangeField)
#SET(%FieldFound,'Yes')
#BREAK
#ENDIF
#ENDFOR
#IF(%FieldFound = %Null)
#SET(%ErrorMessage, (%Procedure & ' ERROR: Key Range Field must be a component of the'))
#ERROR(%ErrorMessage)
#SET(%ErrorMessage, ' File Access Key')
#ERROR(%ErrorMessage)
#ENDIF
#ENDIF
#!
#!***************************************************************************
#GROUP(%ListErrorCheck)
#!
#IF(%Primary = %Null)
#SET(%ErrorMessage, (%Procedure & ' ERROR: No file has been chosen for this procedure.'))
#ERROR(%ErrorMessage)
#SET(%ErrorMessage, ' A file must be identified on the File Schematic.')
#ERROR(%ErrorMessage)
#ENDIF
#IF(%KeyRangeField)
#IF(%KeyRangeField = %RangeValue)
#SET(%ErrorMessage, (%Procedure & ' ERROR: Range Limit Field and Range Value fields must'))
#ERROR(%ErrorMessage)
#SET(%ErrorMessage, ' be separate fields.')
#ERROR(%ErrorMessage)
#ENDIF
#IF(%KeyRangeField <> %Null and %RecordOrder <> %Null)
#SET(%ErrorMessage, (%Procedure & ' ERROR: Range Limits may only be used with keyed order.'))
#ERROR(%ErrorMessage)
#SET(%ErrorMessage, ' Record order has been selected.')
#ERROR(%ErrorMessage)
#ENDIF
#ENDIF
#!
#!***************************************************************************
#GROUP(%BuildListIndex)
#FIX(%File, %Primary)
#FIX(%Key, %PrimaryKey)
#IF(%KeyIndex)
BUILD(%PrimaryKey) #<!Build the index
#ENDIF
#!
#!***************************************************************************
#GROUP(%SaveRangeFields)
#IF(%KeyRangeField)
#SET(%Found, %Null)
#FOR(%KeyField)
#IF(%Found <> 'Yes')
SAV::%KeyField = %KeyField #<!Save range limit fields
#ENDIF
#IF(%KeyField = %KeyRangeField)
#SET(%Found, 'Yes')
#ENDIF
#ENDFOR
#ENDIF
#!
#!***************************************************************************
#GROUP(%RestoreRangeFields)
#IF(%KeyRangeField)
#IF(%RangeValue)
%KeyRangeField = %RangeValue
#ELSE
#SET(%Found, %Null)
#FOR(%KeyField)
#IF(%Found <> 'Yes')
%KeyField = SAV::%KeyField #<! Restore range limit fields
#ENDIF
#IF(%KeyField = %KeyRangeField)
#SET(%Found, 'Yes')
#ENDIF
#ENDFOR
#ENDIF
#ENDIF
#!
#!***************************************************************************
#GROUP(%ClearFileFields)
CLEAR(%FilePre:Record) #<!CLEAR Record buffer
#FOR(%FileMemo)
CLEAR(%FileMemo) #<!CLEAR Memo buffer
#ENDFOR
#CHAIN('CLARION4.TPX')