`
Templates: Globally putting code into events on entry fields 2000-02-01 -- Roberto Artigas Jr Newsgroups: TopSpeed.Topic.Templates
Editors note: Please note that some lines may wrap in the template code.
Heavenes James - This should give you some ideas.
Enjoy!
Roberto Artigas Jr
#RESTRICT,WHERE(%Window)
#ENDRESTRICT
#SHEET,HSCROLL
#TAB('Fi&elds')
#BOXED('')
#BUTTON('Date Fields and Lookup
Buttons'),AT(,,173,),MULTI(%FTDate,%AFieldF & ' ' & %AFieldL & ' ' &
%AFieldS & ' ' & %AFieldB & ' ' & %AFieldT)
#PROMPT('F:Date Field Name: ',@S20),%AFieldF,REQ,UNIQUE,DEFAULT('')
#PROMPT('L:Date LONG Name: ',@S20),%AFieldL,REQ,DEFAULT('')
#PROMPT('S:Date STRING Name: ',@S20),%AFieldS,REQ,DEFAULT('')
#PROMPT('B:Date Lookup Button: ',@S20),%AFieldB,DEFAULT('')
#PROMPT('T:Date Lookup Title: ',@S60),%AFieldT,DEFAULT('')
#DISPLAY
#DISPLAY('The date definitions will create the MOST of the code')
#DISPLAY('necessary. They will convert the original file date fields')
#DISPLAY('on a change to the memory areas. And it will convert them')
#DISPLAY('back to file fields when you are done with the changes.')
#DISPLAY('It will also add the code necessary to process dates when')
#DISPLAY('you enter them. And it will add the code to perform the')
#DISPLAY('calendar lookup operation. Pretty GOOD for a template.')
#DISPLAY
#DISPLAY('You ARE RESPONSIBLE to make sure the definitions are')
#DISPLAY('in the DATA area of your procedure. You have to define')
#DISPLAY('them. And that the memory string date definition is on')
#DISPLAY('the screen rather than the file one.')
#DISPLAY
#ENDBUTTON
#DISPLAY('You have to tell me exactly what date fields and their')
#DISPLAY('memory areas (LONG and STRING) exist.')
#DISPLAY('')
#ENDBOXED
#ENDTAB
#ENDSHEET
#!====================================================================
#! 1999.02.11 - Roberto Artigas Jr
#! This is for generation of DATE selection code
#AT(%ControlEventHandling,,'Selected'),PRIORITY(4000),WHERE(%ControlType='ENTRY')
#FOR(%FTDate)
#SET(%theField,'?' & %AFieldS)
#IF(UPPER(CLIP(%Control))=UPPER(CLIP(%theField)))
!BOE(ENTRY) - Date Field Selected
%theField{PROP:Touched} = TRUE
!EOE(ENTRY) - Date Field Selected
#ENDIF
#ENDFOR
#ENDAT
#!====================================================================
#! 1999.02.11 - Roberto Artigas Jr
#! This is for generation of DATE accepted code
#AT(%ControlEventHandling,,'Accepted'),PRIORITY(4000),WHERE(%ControlType='EN
TRY')
#FOR(%FTDate)
#SET(%theField,'?' & %AFieldS)
#IF(UPPER(CLIP(%Control))=UPPER(CLIP(%theField)))
!BOE(ENTRY) - Date Field Accepted
%AFieldL = fnDateInput(%AFieldS)
DISPLAY(%theField)
!EOE(ENTRY) - Date Field Accepted
#ENDIF
#ENDFOR
#ENDAT
#!====================================================================
#! 1999.02.11 - Roberto Artigas Jr
#! This is for generation of DATE lookup button code
#AT(%ControlEventHandling,,'Accepted'),PRIORITY(4000),WHERE(%ControlType='BUTTON')
#FOR(%FTDate)
#SET(%strField,'?' & %AFieldS)
#SET(%theField,'?' & %AFieldB)
#IF(UPPER(CLIP(%Control))=UPPER(CLIP(%theField)))
!BOE(BUTTON) - Date Lookup Accepted
IF fnDateCalendar('%AFieldT', %AFieldL, %AFieldS) THEN
#EMBED(%DateIsSelected,'Date Is Selected')
ELSE
#EMBED(%NoDateSelected,'No Date Selected')
END
SELECT(%strField)
DISPLAY(%strField)
!EOE(BUTTON) - Date Lookup Accepted
#ENDIF
#ENDFOR
#ENDAT
Please NOTE that the date fields are ENTERED in the button and the code is
generated based on the fields entered.
Enjoy!
Roberto Artigas Jr
Printed October 25, 2026, 6:39 am This article has been viewed/printed 36236 times. Google search has resulted in 31 hits on this article since January 25, 2004. |