home *** CD-ROM | disk | FTP | other *** search
- *******************************************************************************
- * PROGRAM: Filter.wfm
- *
- * WRITTEN BY: Borland Samples Group
- *
- * DATE: 1/94
- *
- * UPDATED: 6/94
- *
- * REVISION: $Revision: 1.25 $
- *
- * VERSION: dBASE FOR WINDOWS 5.0
- *
- * DESCRIPTION: This form allows setting a filter on the items currently
- * viewed. It allows you to create a combination filter based
- * on the artist, title, price, release date, and media type
- * of the available items from the Musical Methods store.
- *
- * PARAMETERS: None
- *
- * CALLS: Music.qbe (view of tables)
- * Music.cc (for custom pushbuttons)
- *
- *
- * USAGE: DO Filter.wfm && or
- *
- * local f
- * set procedure to Filter.wfm additive
- * f = new FilterForm()
- * f.ReadModal
- *******************************************************************************
- #include <Messdlg.h>
- #include "Music.h"
- #define EMPTY_OP " "
- #define EMPTY_LOGIC " "
- #define EMPTY_STRING " "
- set talk off
- set ldcheck off
-
- ** END HEADER -- do not remove this line*
- * Generated on 05/12/94
- *
- LOCAL f
- f = NEW FILTERFORM()
- f.Open()
-
- CLASS FILTERFORM OF FORM
- Set Procedure To Music.cc Additive
- this.OnOpen = CLASS::ONOPEN
- this.OnSelection = CLASS::ONSELECTION
- this.OnClose = CLASS::ONCLOSE
- this.MousePointer = 1
- this.ColorNormal = "R/W"
- this.Text = "Set Filter"
- this.Width = 96.64
- this.Top = 2.02
- this.Left = 2.70
- this.Height = 17.17
- this.Minimize = .F.
- this.Maximize = .F.
- this.HelpFile = ""
- this.HelpId = ""
-
-
- DEFINE RECTANGLE MEDIATYPERECT OF THIS;
- PROPERTY;
- ColorNormal "N/W",;
- Text "",;
- Height 2.02,;
- Width 94.61,;
- Top 10.61,;
- Left 0.67,;
- Border .T.
-
- DEFINE RECTANGLE RELEASEDATERECT OF THIS;
- PROPERTY;
- ColorNormal "N/W",;
- Text "",;
- Height 2.02,;
- Width 94.61,;
- Top 8.58,;
- Left 0.67,;
- Border .T.
-
- DEFINE RECTANGLE SALESPRICERECT OF THIS;
- PROPERTY;
- ColorNormal "N/W",;
- Text "",;
- Height 2.02,;
- Width 94.61,;
- Top 6.57,;
- Left 0.67,;
- Border .T.
-
- DEFINE RECTANGLE RANKRECT OF THIS;
- PROPERTY;
- ColorNormal "N/W",;
- Text "",;
- Height 2.02,;
- Width 94.61,;
- Top 4.55,;
- Left 0.67,;
- Border .T.
-
- DEFINE RECTANGLE TITLERECT OF THIS;
- PROPERTY;
- ColorNormal "N/W",;
- Text "",;
- Height 2.02,;
- Width 94.61,;
- Top 2.53,;
- Left 0.67,;
- Border .T.
-
- DEFINE RECTANGLE ARTISTRECT OF THIS;
- PROPERTY;
- ColorNormal "N/W",;
- Text "",;
- Height 2.02,;
- Width 94.61,;
- Top 0.50,;
- Left 0.67,;
- Border .T.
-
- DEFINE NORMALTEXT ARTISTTEXT OF THIS;
- PROPERTY;
- Alignment 5,;
- Text "Artist:",;
- Width 16.22,;
- Top 1.01,;
- Left 1.35,;
- Height 1.01,;
- Border .F.
-
- DEFINE NORMALENTRY ARTISTENTRY OF THIS;
- PROPERTY;
- OnGotFocus CLASS::ONGOTFOCUSFIELD,;
- OnLostFocus CLASS::ONLOSTFOCUSFIELD,;
- Enabled .T.,;
- Width 40.55,;
- Top 1.01,;
- Left 31.08,;
- Height 1.07,;
- Value " ",;
- Function "!"
-
- DEFINE COMBOBOX ARTISTOPCOMBO OF THIS;
- PROPERTY;
- Enabled .F.,;
- Width 8.11,;
- Top 1.01,;
- Left 18.92,;
- Height 1.26,;
- FontSize 7.00,;
- Style 2
-
- DEFINE COMBOBOX ARTISTLOGICCOMBO OF THIS;
- PROPERTY ;
- Enabled .F.,;
- Width 10.81, ;
- Top 1.01, ;
- Left 72.98, ;
- Height 1.26, ;
- Value "", ;
- Style 2
-
- DEFINE PUSHBUTTON CLEARARTISTBUTTON OF THIS;
- PROPERTY;
- Id 1,;
- OnClick CLASS::CLEARARTIST,;
- Text "Clear",;
- Width 6.76,;
- Top 1.01,;
- Left 86.53,;
- Height 1.01
-
- DEFINE NORMALTEXT TITLETEXT OF THIS;
- PROPERTY;
- Alignment 5,;
- Text "Title:",;
- Width 16.22,;
- Top 3.03,;
- Left 1.35,;
- Height 1.21
-
- DEFINE COMBOBOX TITLEOPCOMBO OF THIS;
- PROPERTY ;
- Enabled .F.,;
- Width 8.11, ;
- Top 3.03, ;
- Left 18.92, ;
- Height 1.26, ;
- Value "", ;
- Style 2
-
- DEFINE NORMALENTRY TITLEENTRY OF THIS;
- PROPERTY;
- OnGotFocus CLASS::ONGOTFOCUSFIELD,;
- OnLostFocus CLASS::ONLOSTFOCUSFIELD,;
- Enabled .T.,;
- Width 40.55,;
- Top 3.03,;
- Left 31.08,;
- Height 1.07,;
- Value " ",;
- Function "!"
-
- DEFINE COMBOBOX TITLELOGICCOMBO OF THIS ;
- PROPERTY ;
- Enabled .F.,;
- Width 10.81, ;
- Top 3.03, ;
- Left 72.98, ;
- Height 1.26, ;
- Value "", ;
- Style 2
-
-
- DEFINE PUSHBUTTON CLEARTITLEBUTTON OF THIS;
- PROPERTY;
- Id 2,;
- OnClick CLASS::CLEARTITLE,;
- Text "Clear",;
- Width 6.76,;
- Top 3.03,;
- Left 86.53,;
- Height 1.01
-
- DEFINE NORMALTEXT RANKTEXT OF THIS;
- PROPERTY;
- Alignment 5,;
- Text "Rank:",;
- Width 16.22,;
- Top 5.05,;
- Left 1.35,;
- Height 1.01
-
- DEFINE COMBOBOX RANKOPCOMBO OF THIS;
- PROPERTY ;
- Enabled .F.,;
- Width 8.11, ;
- Top 5.05, ;
- Left 18.92, ;
- Height 1.26, ;
- Value "", ;
- Style 2
-
- DEFINE SPINBOX RANKSPIN OF THIS;
- PROPERTY;
- OnGotFocus CLASS::ONGOTFOCUSFIELD,;
- OnLostFocus CLASS::ONLOSTFOCUSFIELD,;
- ColorNormal "r/w",;
- Picture "9999",;
- Function "J",;
- Width 13.52,;
- Top 5.05,;
- Left 31.08,;
- Height 1.07,;
- Border .T.,;
- Value 0,;
- Rangemin 0,;
- Rangemax 2500,;
- ColorHighLight "r/w*"
-
-
- DEFINE COMBOBOX RANKLOGICCOMBO OF THIS;
- PROPERTY ;
- Enabled .F.,;
- Width 10.81, ;
- Top 5.05, ;
- Left 72.98, ;
- Height 1.26, ;
- Value "", ;
- Style 2
-
- DEFINE PUSHBUTTON CLEARRANKBUTTON OF THIS;
- PROPERTY;
- Id 3,;
- OnClick CLASS::CLEARRANK,;
- Text "Clear",;
- Width 6.76,;
- Top 5.05,;
- Left 86.53,;
- Height 1.01
-
- DEFINE NORMALTEXT SALESPRICETEXT OF THIS;
- PROPERTY;
- Alignment 5,;
- Text "Sales Price:",;
- Width 16.22,;
- Top 7.07,;
- Left 1.35,;
- Height 1.01
-
- DEFINE COMBOBOX SALESPRICEOPCOMBO OF THIS;
- PROPERTY ;
- Enabled .F.,;
- Width 8.11, ;
- Top 7.07, ;
- Left 18.92, ;
- Height 1.26, ;
- Value "", ;
- Style 2
-
- DEFINE SPINBOX SALESPRICESPIN OF THIS;
- PROPERTY;
- OnGotFocus CLASS::ONGOTFOCUSFIELD,;
- OnLostFocus CLASS::ONLOSTFOCUSFIELD,;
- ColorNormal "r/w",;
- Width 13.52,;
- Top 7.07,;
- Left 31.08,;
- Height 1.01,;
- Border .T.,;
- Value 0,;
- Rangemin 1,;
- Rangemax 100,;
- ColorHighLight "r/w*",;
- Picture "999.99",;
- Function "$J"
-
- DEFINE COMBOBOX SALESPRICELOGICCOMBO OF THIS;
- PROPERTY ;
- Enabled .F.,;
- Width 10.81, ;
- Top 7.07, ;
- Left 72.98, ;
- Height 1.26, ;
- Value "", ;
- Style 2
-
- DEFINE PUSHBUTTON CLEARSALESPRICEBUTTON OF THIS;
- PROPERTY;
- Id 5,;
- OnClick CLASS::CLEARSALESPRICE,;
- Text "Clear",;
- Width 6.76,;
- Top 7.07,;
- Left 86.53,;
- Height 1.01
-
- DEFINE NORMALTEXT RELEASEDATETEXT OF THIS;
- PROPERTY;
- Alignment 5,;
- Text "Release Date:",;
- Width 16.22,;
- Top 9.09,;
- Left 1.35,;
- Height 1.01
-
- DEFINE COMBOBOX RELEASEDATEOPCOMBO OF THIS;
- PROPERTY ;
- Enabled .F.,;
- Width 8.11, ;
- Top 9.09, ;
- Left 18.92, ;
- Height 1.26, ;
- Value "", ;
- Style 2
-
- DEFINE ENTRYFIELD RELEASEDATEENTRY OF THIS;
- PROPERTY;
- OnGotFocus CLASS::ONGOTFOCUSFIELD,;
- OnLostFocus CLASS::ONLOSTFOCUSFIELD,;
- ColorNormal "r/w",;
- Width 13.52,;
- Top 9.09,;
- Left 31.08,;
- Height 1.07,;
- Border .T.,;
- Value { / / },;
- ColorHighLight "r/w*",;
- Function "DJ"
-
- DEFINE COMBOBOX RELEASEDATELOGICCOMBO OF THIS;
- PROPERTY ;
- Enabled .F.,;
- Width 10.81, ;
- Top 9.09, ;
- Left 72.98, ;
- Height 1.26, ;
- Value "", ;
- Style 2
-
- DEFINE PUSHBUTTON CLEARRELEASEDATEBUTTON OF THIS;
- PROPERTY;
- Id 4,;
- OnClick CLASS::CLEARRELEASEDATE,;
- Text "Clear",;
- Width 6.76,;
- Top 9.09,;
- Left 86.53,;
- Height 1.01
-
-
- DEFINE NORMALTEXT MEDIATYPETEXT OF THIS;
- PROPERTY;
- Alignment 5,;
- Text "Media Type:",;
- Width 16.22,;
- Top 11.11,;
- Left 1.35,;
- Height 1.21
-
-
- DEFINE COMBOBOX MEDIATYPEOPCOMBO OF THIS;
- PROPERTY ;
- Enabled .F.,;
- Width 8.11, ;
- Top 11.11, ;
- Left 18.92, ;
- Height 1.26, ;
- Value "", ;
- Style 2
-
-
- DEFINE COMBOBOX MEDIATYPECOMBO OF THIS;
- PROPERTY;
- OnGotFocus CLASS::ONGOTFOCUSFIELD,;
- OnLostFocus CLASS::ONLOSTFOCUSFIELD,;
- Width 40.55,;
- Top 11.11,;
- Left 31.08,;
- Height 1.26,;
- Value " ",;
- Style 2
-
- DEFINE PUSHBUTTON CLEARMEDIATYPEBUTTON OF THIS;
- PROPERTY;
- Id 6,;
- OnClick CLASS::CLEARMEDIATYPE,;
- Text "Clear",;
- Width 6.76,;
- Top 11.11,;
- Left 86.53,;
- Height 1.01
-
- DEFINE IMAGE LOGOIMAGE OF THIS;
- PROPERTY;
- Width 10.81,;
- Top 13.13,;
- Left 1.35,;
- Height 3.03,;
- DataSource "FILENAME SMLMUSIC.BMP"
-
- DEFINE OKBUTTON FILTEROKBUTTON OF THIS;
- PROPERTY;
- Width 14.11,;
- Top 14.14,;
- Left 64.87,;
- Height 1.50,;
- Default .T.,;
- Group .T.
-
- DEFINE CANCELBUTTON FILTERCANCELBUTTON OF THIS;
- PROPERTY;
- Width 14.11,;
- Top 14.14,;
- Left 79.74,;
- Height 1.50,;
- ID 0,;
- Group .F.
-
-
- *******************************************************************************
- procedure OnOpen
- *******************************************************************************
- this.saveExact = set("exact")
- this.saveFields = setto("fields")
- setSkip = "Music"
- if empty(alias())
- set view to Music.qbe
- endif
- use configs again in select() alias configs2 order descript
- set exact off
- set fields to
- set skip to &setSkip
-
- this.CreateArrays()
-
- this.mediaTypeCombo.dataSource = "array form.configsAr"
- this.artistOpCombo.dataSource = "array form.charOpAr"
- this.titleOpCombo.dataSource = "array form.charOpAr"
- this.rankOpCombo.dataSource = "array form.operatorAr"
- this.salesPriceOpCombo.dataSource = "array form.operatorAr"
- this.releaseDateOpCombo.dataSource = "array form.operatorAr"
- this.mediaTypeOpCombo.dataSource = "array form.charOpAr"
- this.artistLogicCombo.dataSource = "array form.logicOpAr"
- this.titleLogicCombo.dataSource = "array form.logicOpAr"
- this.rankLogicCombo.dataSource = "array form.logicOpAr"
- this.salesPriceLogicCombo.dataSource = "array form.logicOpAr"
- this.releaseDateLogicCombo.dataSource = "array form.logicOpAr"
-
- this.artistEntry.prevObj = this.artistOpCombo
- this.titleEntry.prevObj = this.titleOpCombo
- this.rankSpin.prevObj = this.rankOpCombo
- this.salesPriceSpin.prevObj = this.salesPriceOpCombo
- this.releaseDateEntry.prevObj = this.releaseDateOpCombo
- this.mediaTypeCombo.prevObj = this.mediaTypeOpCombo
-
- this.artistEntry.nextObj = this.artistLogicCombo
- this.titleEntry.nextObj = this.titleLogicCombo
- this.rankSpin.nextObj = this.rankLogicCombo
- this.salesPriceSpin.nextObj = this.salesPriceLogicCombo
- this.releaseDateEntry.nextObj = this.releaseDateLogicCombo
- this.mediaTypeCombo.nextObj = this.mediaTypeCombo.prevObj && no combobox
- && after media types
- *******************************************************************************
- procedure OnClose
- *******************************************************************************
- private saveExact, saveFields
- set skip to
- saveExact = this.saveExact
- saveFields = this.saveFields
- set exact &saveExact
- set fields to &saveFields
- use in configs2 && Close temporary configs table
-
- *** If form is not opened modally
- if _app.framewin.text = "Musical Methods"
- this.viewForm.filter = set("filter")
- endif
-
-
- *******************************************************************************
- procedure OnGotFocusField
- *******************************************************************************
- if empty(this.prevObj.value)
- this.prevObj.value = " is "
- endif
- if .not. empty(this.nextObj) .and. empty(this.nextObj.value)
- this.nextObj.value = "and"
- endif
-
- *******************************************************************************
- procedure OnLostFocusField
- *******************************************************************************
- if empty(this.value) && Nothing was entered
- this.nextObj.value = " "
- this.nextObj.enabled = .f.
- this.prevObj.value = " "
- this.prevObj.enabled = .f.
- else && Enable comboboxes if they exist
- if .not. empty(this.nextObj) && (MediaTypeCombo doesn't have nextObj)
- this.nextObj.enabled = .t.
- if empty(this.nextObj.value)
- this.nextObj.value = "and"
- endif
- endif
- this.prevObj.enabled = .t.
- if empty(this.prevObj.value) && if no operator, assign one
- this.prevObj.value = " is "
- endif
- endif
-
-
- *******************************************************************************
- procedure CreateArrays
- *******************************************************************************
- local arrayRef && variable for minimizing property access
-
- * combobox datasource arrays
- this.operatorAr = new array(5)
- this.charOpAr = new array(3)
- this.logicOpAr = new array(3)
- this.configsAr = new array(reccount("configs2") + 1) && add 1 for empty value
-
- arrayRef = this.operatorAr
- arrayRef[1] = " "
- arrayRef[2] = " is "
- arrayRef[3] = "isn't"
- arrayRef[4] = "< "
- arrayRef[5] = "> "
-
- acopy(this.operatorAr,this.charOpAr,1,3) && only want "is" and "isn't"
-
- arrayRef = this.logicOpAr
- arrayRef[1] = " "
- arrayRef[2] = "and"
- arrayRef[3] = "or "
-
- arrayRef = this.configsAr
- arrayRef[1] = " "
- arrayRef[2] = '12" VINYL'
- arrayRef[3] = "COMPACT DISC"
- arrayRef[4] = "VHS VIDEO"
- arrayRef[5] = "CASSETTE"
- arrayRef[6] = "DIGITAL COMPACT CASSETTE"
- arrayRef[7] = '12" LASER DISC'
- arrayRef[8] = "MINI-DISC"
- arrayRef[9] = "ACCESSORIES"
-
- *******************************************************************************
- Procedure OnSelection(controlId)
- *******************************************************************************
- private filterVar, strConfig, saveFilter, saveRec, closeForm, curTable
- form.selectedId = controlId && Indicates to calling procedure what
- closeForm = .f.
- curTable = alias()
- do case && control was selected
- case controlId > 0 && Clear buttons were selected -- don't do anything
- case controlId = 0 && Cancel was selected
- closeForm = .t.
- otherwise
- filterVar = ""
- if .not. empty(this.artistEntry.value) && Artist was entered
- filterVar = " Music->Artist " +;
- this.DecodeOp(this.artistOpCombo) +;
- '"' + ALLTRIM(this.artistEntry.value) + '"' +;
- this.DecodeOp(this.artistLogicCombo)
- endif
- if .not. empty(this.titleEntry.value) && Title was entered
- filterVar = filterVar + " Music->Title " +;
- this.DecodeOp(this.titleOpCombo) +;
- '"' + ALLTRIM(this.titleEntry.value) + '"' +;
- this.DecodeOp(this.titleLogicCombo)
- endif
- if .not. empty(this.rankSpin.value) && Rank was entered
- filterVar = filterVar + " Music->Rank " +;
- this.DecodeOp(this.rankOpCombo) +;
- str(this.rankSpin.value,4) +;
- this.DecodeOp(this.rankLogicCombo)
- endif
- if .not. empty(this.salesPriceSpin.value) && Sales Price was entered
- filterVar = filterVar + " Music->List_Price " +;
- this.DecodeOp(this.salesPriceOpCombo) +;
- stuff(str(this.salesPriceSpin.value,6,2),4,1,".") +;
- this.DecodeOp(this.salesPriceLogicCombo)
- endif
- if .not. empty(this.releaseDateEntry.value) && Release Date was entered
- filterVar = filterVar + " Music->Street_Dt " +;
- this.DecodeOp(this.releaseDateOpCombo) +;
- "ctod('" +dtoc(this.releaseDateEntry.value) + "')" +;
- this.DecodeOp(this.ReleaseDateLogicCombo)
- endif
- if .not. empty(this.mediaTypeCombo.value) && Media Type was specified
- select configs2
- seek this.mediaTypeCombo.value
- strConfig = str(configs2->config)
- select &curTable
- filterVar = filterVar + " Music->Config " +;
- this.DecodeOp(this.mediaTypeOpCombo) +;
- strConfig
- endif
- * If last word was .and./.or., delete it
- if CLASS::BackRat(" .or. ",filterVar) = 7 .or.;
- CLASS::BackRat(" .and. ",filterVar) = 7
- filterVar = substr(filterVar,1,len(filterVar) - 7)
- endif
- saveRec = iif(eof(), recno() - 1, recno())
- saveFilter = set("filter")
-
- select music
- set filter to &filterVar
- go top
-
- select &curTable
- set filter to &filterVar
- go top
-
- if eof() && no matching records
- set filter to &saveFilter
- go top
- go saveRec
- if ConfirmationMessage("No matching data was found. Continue?",;
- "Sorry") = NO
- closeForm = .t.
- endif
- else && matching records
- form.filter = filterVar
- if type("form.viewForm") <> "U"
- form.viewForm.filter = filterVar && Save filter in view form
- endif
- closeForm = .t.
- endif
- endcase
- if closeForm
- form.Close()
- endif
-
-
- *******************************************************************************
- procedure DecodeOp(opControl)
- *******************************************************************************
- private op,decodedOp
- op = opControl.value
- decodedOp = op && some are directly transferable, but
- do case && the case statement handles ones that aren't
- case op = " is "
- decodedOp = " = "
- case op = "isn't"
- decodedOp = " <> "
- case op = "and"
- decodedOp = " .and. "
- case op = "or "
- decodedOp = " .or. "
- endcase
- return decodedOp
-
- *******************************************************************************
- Procedure ClearArtist
- *******************************************************************************
- form.artistOpCombo.value = EMPTY_OP
- form.artistEntry.value = space(30)
- form.artistLogicCombo.value = EMPTY_LOGIC
- form.artistEntry.OnLostFocus()
-
- *******************************************************************************
- Procedure ClearTitle
- *******************************************************************************
- form.titleOpCombo.value = EMPTY_OP
- form.titleEntry.value = space(30)
- form.titleLogicCombo.value = EMPTY_LOGIC
- form.titleEntry.OnLostFocus()
-
- *******************************************************************************
- Procedure ClearRank
- *******************************************************************************
- form.rankOpCombo.value = EMPTY_OP
- form.rankSpin.value = 0
- form.rankLogicCombo.value = EMPTY_LOGIC
- form.rankSpin.OnLostFocus()
-
- *******************************************************************************
- Procedure ClearSalesPrice
- *******************************************************************************
- form.salesPriceOpCombo.value = EMPTY_OP
- form.salesPriceSpin.value = 0
- form.salesPriceLogicCombo.value = EMPTY_LOGIC
- form.salesPriceSpin.OnLostFocus()
-
- *******************************************************************************
- Procedure ClearReleaseDate
- *******************************************************************************
- form.releaseDateOpCombo.value = EMPTY_OP
- form.releaseDateEntry.value = {//}
- form.releaseDateLogicCombo.value = EMPTY_LOGIC
- form.releaseDateEntry.OnLostFocus()
-
- *******************************************************************************
- Procedure ClearMediaType
- *******************************************************************************
- form.mediaTypeOpCombo.value = EMPTY_OP
- form.mediaTypeCombo.value = " "
- form.mediaTypeCombo.OnLostFocus()
-
-
- ***********************************************************
- function BackRat(searchStr, targetStr)
- **********************************************************
- local lenTarget, lenSearch, foundLoc
- lenTarget = len(targetStr)
- lenSearch = len(searchStr)
- foundLoc = rat(searchStr, targetStr)
- return iif(foundLoc = 0,;
- 0,;
- lenTarget - foundLoc + 1)
-
- ENDCLASS
-
-
-
-
-