Uncommon Knowledge - WC_Query_Template%

Published ByDateVersionKnowledge LevelKeywords
Sprezzatura Ltd01 JAN 19922.11+EXPERTWINDOW_COMMON%, WC_QUERY_TEMPLATE%

The template definition used when query mode is invoked. Note that initially this variable is empty but that it is constructed when query mode is invoked for the first time. If however the programmer has already loaded WC_Query_Template% appropriately, this will be used instead. Thus it is possible for query to invoke any template when the user requests it. This makes it possible for the programmer to put back in necessary edit checks and post prompt checks etc. It even makes possible the display of a radically different screen designed exclusively for query purposes.

The revised template can be loaded into WC_Query_Template% after initialisation. The template can either be prepared with the appropriate softkey and collector hooks or constructed on the fly using code like that provided below. Note that this code is intended as indicational only - it may require modification for your specific application. To use just call passing the name of the template to establish as the query window.

Subroutine Create_Query_Template(Template_To_Use)
/*
 Author        AMcA
 Date          Jan 1991
 Purpose       To build a query template from a template on file
*/

 $insert include,window_common%
 $insert include,lcfunctions
 Equ Delim$ To Char(247)
 Template_Rec = Xlate("TEMPLATES", Template_To_Use, "", "X")
 SOFTKEYS = "SFýChange Sort/SelectýQUERY.SUB,CUSTOMIZE" : @FM
 SOFTKEYS := "SFýSave Criteria as FilterýQUERY.SUB,FILTER.SAVE"
 Collector = "S" : @FM : "QUERY.SUB,CHECK.REDISPLAY" : @FM
 Collector := @FM : "S":@FM:"QUERY.SUB,MAKE.SELECT":@FM : "1"
 * Remove all processes other than pre query
 Pre = STR(@FM,5):WC_PREPROC%<6>
 /*
  If environment char not loaded may need default logic here
  Query_Char = Char(@Environ.Set<56>)
 */
 W_Env = STR(@FM,5):Query_Char
 Title = field(Template_Rec,Delim$,6):"- Query Window!"
 Y = (Template_Rec<1>+1)
 Prompts = FIELD( Template_Rec, @FM, 1, Y )
 Template_Rec[1,COL2()] = ""
 Prompt_Number = 1
 For Pointer = 2 To Y
  Prompts<Pointer,3> = "F" ; * Even symbolics become F type
  Prompts<Pointer,18> = "" ; * Remove Required flags
  Prompts<Pointer,22> = 1 ; * Make lower case
  Prompts<Pointer,4> = Prompt_Number ; Prompt_Number += 1
 Next
 Template_Rec = FIELDSTORE( Template_Rec, Delim$, 6, 1, Title )
 * Add in collector details
 Template_Rec = FIELDSTORE( Template_Rec, Delim$, 13, 1, Collector)
 * Don't bother locking or with required fields, keys, AMVs or recalc
 Template_Rec = FIELDSTORE( Template_Rec, Delim$, 14, 1, 0 )
 Template_Rec = FIELDSTORE( Template_Rec, Delim$, 16, 1, "" )
 Template_Rec = FIELDSTORE( Template_Rec, Delim$, 17, 1, "" )
 Template_Rec = FIELDSTORE( Template_Rec, Delim$, 19, 1, "" )
 Template_Rec = FIELDSTORE( Template_Rec, Delim$, 21, 1, "" )
 Template_Rec = FIELDSTORE( Template_Rec, Delim$, 22, 1, "" )
 Template_Rec = FIELDSTORE( Template_Rec, Delim$, 23, 1, "" )
 Template_Rec = FIELDSTORE( Template_Rec, Delim$, 24, 1, "" )
 * Add in SF1 and SF2
 Template_Rec = FIELDSTORE( Template_Rec, Delim$, 26, 1, SF1:@FM:SF2)
 Template_Rec = FIELDSTORE( Template_Rec, Delim$, 27, 1, SOFTKEYS )
 * Remove all preprocesses, post and rep
 Template_Rec = FIELDSTORE( Template_Rec, Delim$, 30, 1, Pre)
 Template_Rec = FIELDSTORE( Template_Rec, Delim$, 31, 1, "" )
 Template_Rec = FIELDSTORE( Template_Rec, Delim$, 32, 1, "" )
 * Null Rec Map and start and disabled keys
 Template_Rec = FIELDSTORE( Template_Rec, Delim$, 34, 1, "" )
 Template_Rec = FIELDSTORE( Template_Rec, Delim$, 42, 1, "" )
 Template_Rec = FIELDSTORE( Template_Rec, Delim$, 43, 1, "" )
 * Remove Perpetual
 Template_Rec = FIELDSTORE( Template_Rec, Delim$, 45, 1, "" )
 * Set default mask
 Template_Rec = FIELDSTORE( Template_Rec, Delim$, 48, 1, W_Env)
 * And finally reassemble the template variable
 WC_QUERY_TEMPLATE% = Prompts:@FM:Template_Rec
return

(Volume 3, Issue 8, Pages 11,12)