Login
`
Templates, Tools and Utilities
|
||
Icetips Article
Back to article list
Search Articles
Add Comment
Printer friendly
Direct link
Par2: Range Limiting by High Values -- ABC Template 1998-07-07 -- Jeff Walters I have posted several messages regarding my penchant for multi-field keys,
with dropdown selections on any of the fields to provide fast and flexible
data displays. A simple modification to 2003 templates enabled me to
implement this without any embed code. however, ABC really didn't prove to
be as simple as ABC. I developed a crude workaround using a File
Relationship to a dummy file last month. Fortunately Jakes van Vuuren took
partial pity on me by suggesting delving into the ApplyRange method. I say
partial pity because exact implementation of his suggestion resulted in
umpteen GPFs / trial by cursing until I had tamed the beast. Having resolved
the coding issues, I quickly created a template to manage the process (as
well as BINDing filter fields, if required), which I think should address
many people's needs.
The process is simple :
- Add the extension template HighKeyFields for the specific BrowseBox
- Set the 2nd, or 3rd KeyField as the Range Limit, set to Current Value
- Point the high KeyFields to local / lookup file fields on the template,
and nominate which control will change the value (if you have no
intention of altering the value once the browse has been opened, you
really don't need this template!)
- I prefer to immediately move the focus to main Browse, so I provide the
option of nominating the next control to select after update.
- I also like to open my multi range browses on my last settings, so have
provided INI support.
No hand coding, simple point and click.
The entire development and testing time was about 8 hours, and has removed
a major source of frustration in my life.
Thanks once again to Jakes
Jeff Walters
e-Mail: jwalters@global.co.za
(Updated 24 July 1998)
#TEMPLATE (ABC_jw, 'High KeyFields for BrowseABC'),Family('ABC')
#!
============================================================================
=============== !#
#! Version: 1.1
!#
#!
!#
#! Author: Jeff Walters
!#
#! Dated : 7/07/98
!#
#! e-Mail: jwalters@global.co.za
!#
#!
!#
#!
============================================================================
=============== !#
#!
#!
#!
============================================================================
=============== !#
#!
#EXTENSION(HigherKeys,'Set / Reset Higher Key fields'),REQ(BrowseBox(ABC))
#!
#!
============================================================================
=============== !#
#!
#BUTTON('Bind / Set Fields'), AT(10,,180)
#SHEET
#TAB('Set Key Fields')
#DISPLAY(''),AT(,,,2)
#DISPLAY('Use to set / reset higher key fields of a Ranged browse.')
#DISPLAY(''),AT(,,,2)
#BOXED('Set Key Fields')
#DISPLAY(''),AT(,,,2)
#BUTTON ('Set Key Fields'), MULTI(%SettingFields, %TargetKeyField &
' = ' & %SettingField),INLINE,AT(,,,60)
#PROMPT ('Key Field:', COMPONENT(%PrimaryKey)), %TargetKeyField,
REQ
#PROMPT ('Set Field:', FIELD), %SettingField, REQ
#DISPLAY(''),AT(,,,2)
#PROMPT ('Use a control to set higher key
value',CHECK),%jwUseSetControl,DEFAULT(1),AT(10)
#BOXED (''),WHERE(%jwUseSetControl),Clear,HIDE
#PROMPT ('Set Field Control:', CONTROL), %SettingControl
#DISPLAY(''),AT(,,,2)
#PROMPT ('Force ''Top Of List'' after Accepted',
CHECK),%jwForceTop,DEFAULT(1),AT(10)
#DISPLAY(''),AT(,,,2)
#DISPLAY ('Ensures the first record of the range is always
selected')
#DISPLAY ('when a range field is changed.')
#DISPLAY (''),AT(,,,2)
#PROMPT ('Select another control after
Accepted',CHECK),%jwSelectNextControl,DEFAULT(0),AT(10)
#ENABLE(%jwSelectNextControl),CLEAR
#DISPLAY(''),AT(,,,2)
#PROMPT ('Control to select after
Accepted',CONTROL),%SelectControl
#ENDENABLE
#ENDBOXED
#ENDBUTTON
#ENDBOXED
#DISPLAY(''),AT(,,,2)
#ENABLE(%INIActive),CLEAR
#PROMPT ('''Remember'' last key settings in INI
file:',CHECK ),%jwRememberKeys,DEFAULT(0),AT(10)
#ENDENABLE
#ENDTAB
#TAB('Bind non-queue fields')
#DISPLAY(''),AT(,,,2)
#DISPLAY('Use for all fields that you wish to BIND, but where you')
#DISPLAY('don''t want the value locked in by Browse''s queue ')
#DISPLAY('processing (which is what the BIND option does on the')
#DISPLAY('''Hot Fields'' tab.)')
#DISPLAY(''),AT(,,,2)
#BOXED('Fields To Bind')
#DISPLAY(''),AT(,,,2)
#BUTTON ('Set Key Fields'), MULTI(%BoundFields,
%BoundField),INLINE,AT(,,,60)
#PROMPT ('BIND Field:', FIELD), %BoundField, REQ
#ENDBUTTON
#ENDBOXED
#ENDTAB
#TAB('Usage')
#DISPLAY(''),AT(,,,2)
#BOXED('')
#DISPLAY(''),AT(,,,2)
#DISPLAY('Assuming the Browse Key with structure (KF1, KF2, KF3)')
#DISPLAY(''),AT(,,,2)
#DISPLAY('1 - Set Key Fields - say KF1 and KF2 - on the first
tab.')
#DISPLAY('2 - Set the Browse range field to KF2 - Current Value')
#DISPLAY('3 - If you are using a Droplist, or parent Browse to ')
#DISPLAY(' provide the Setting Field values, ensure that they')
#DISPLAY(' are ''Hot'' on the Browse, or set as target fields')
#DISPLAY(' on the Droplists.')
#DISPLAY('4 - QED. Enjoy! ')
#ENDBOXED
#ENDTAB
#ENDSHEET
#ENDBUTTON
#! -------------------------------------------------------------------------
------------------ !#
#ATSTART
#DECLARE(%jwHKListInstance)
#SET(%jwHKListInstance,%ActiveTemplateParentInstance)
#DECLARE(%jwBrowseID)
#SET(%jwBrowseID,SLICE(%InstancePrefix,1,LEN(%InstancePrefix)-1))
#DECLARE(%FullSectionName)
#SET(%FullSectionName,%Procedure & '::Higher Keys')
#ENDAT
#! -------------------------------------------------------------------------
------------------ !#
#AT(%WindowManagerMethodCodeSection,'Init','(),BYTE'),PRIORITY(7600)
#IF(%jwRememberKeys AND ITEMS(%SettingFields))
#CALL(%Header, 'Higher Keys - Last
Values')
#FOR(%SettingFields)
%[15]SettingField = INIMgr.TryFetch('%FullSectionName','%SettingField')
#ENDFOR
#CALL(%Header, 'Higher Keys - Last
Values')
#ENDIF
#!
#IF (ITEMS(%BoundFields))
#CALL(%Header,'Bound Fields')
#ENDIF
#FOR(%BoundFields)
BIND('%BoundField',%BoundField)
#ENDFOR
#IF (ITEMS(%BoundFields))
#CALL(%Header,'Bound Fields')
#ENDIF
#ENDAT
#! -------------------------------------------------------------------------
------------------ !#
#AT(%BrowserMethodCodeSection,%jwHKListInstance,'ApplyRange','(),BYTE'),PRIO
RITY(4000)
#IF (ITEMS(%SettingFields))
#CALL(%Header,'Higher Keys')
#ENDIF
#DECLARE(%jwKeyFieldInstance)
#FIX(%Key,%PrimaryKey)
#FOR (%SettingFields)
#FIX(%KeyField,%TargetKeyField)
#IF(%KeyField)
#SET(%jwKeyFieldInstance,INSTANCE(%KeyField))
GET(SELF.Order.RangeList.List,%jwKeyFieldInstance)
Self.Order.RangeList.List.Right = %SettingField
#ENDIF
#ENDFOR
#IF (ITEMS(%SettingFields))
#CALL(%Header,'Higher Keys')
#ENDIF
#ENDAT
#! -------------------------------------------------------------------------
------------------ !#
#AT(%ControlEventHandling,,'Accepted'),PRIORITY(7500)
#FOR(%SettingFields)
#IF(%Control = %SettingControl AND %ControlType <> 'SHEET')
#CALL(%Header,'Higher Keys')
#IF(%jwForceTop)
Free(%jwBrowseID.ListQueue)
#ENDIF
%jwBrowseID.ApplyRange
%jwBrowseID.ResetSort(1)
#IF(%SelectControl)
Select(%SelectControl)
#ENDIF
#CALL(%Header,'Higher Keys')
#BREAK
#ENDIF
#ENDFOR
#ENDAT
#! -------------------------------------------------------------------------
------------------ !#
#AT(%ControlEventHandling,,'NewSelection'),PRIORITY(9000)
#FOR(%SettingFields)
#IF(%Control = %SettingControl AND %ControlType = 'SHEET')
#CALL(%Header,'Higher Keys')
#IF(%jwForceTop)
Free(%jwBrowseID.ListQueue)
#ENDIF
%jwBrowseID.ApplyRange
%jwBrowseID.ResetSort(1)
#IF(%SelectControl)
Select(%SelectControl)
#ENDIF
#CALL(%Header,'Higher Keys')
#BREAK
#ENDIF
#ENDFOR
#ENDAT
#! -------------------------------------------------------------------------
------------------ !#
#AT(%WindowManagerMethodCodeSection,'Kill','(),BYTE'),PRIORITY(9000)
#IF(%jwRememberKeys AND ITEMS(%SettingFields))
#CALL(%Header, 'Higher Keys')
#FOR(%SettingFields)
INIMgr.Update('%FullSectionName','%SettingField',%SettingField)
#ENDFOR
#CALL(%Header, 'Higher Keys')
#ENDIF
#ENDAT
#!
#! -------------------------------------------------------------------------
------------------ !#
#GROUP(%HEADER,%HeaderDescription)
#!
#DECLARE (%HeaderLength)
#DECLARE (%LeftOfHeader)
#DECLARE (%LeftOfHeaderLength)
#DECLARE (%RightOfHeader)
#DECLARE (%RightOfHeaderLength)
#SET (%HeaderLength, LEN(%HeaderDescription))
#IF (%HeaderLength)
#SET (%LeftOfHeaderLength, 45 - INT(%HeaderLength/2))
#SET (%RightOfHeaderLength, 90 - %HeaderLength - %LeftOfHeaderLength)
#SET (%LeftOfHeader, ALL('-', %LeftOfHeaderLength))
#SET (%RightOfHeader, ALL('-', %RightOfHeaderLength))
! %LeftOfHeader %HeaderDescription %RightOfHeader !
#ELSE
#SET (%LeftOfHeader, ALL('-', 92))
! %LeftOfHeader !
#ENDIF
#!
Today is November 21, 2024, 3:36 am This article has been viewed 35204 times.
|
|