User Tools

Site Tools


querylistclass_conceptual_example.htm
Navigation:  ABC Library Reference > QueryListClass >====== QueryListClass–Conceptual Example C6H0009.jpg ====== Previous pageReturn to chapter overviewNext page

The following example shows a typical sequence of statements to declare, instantiate, initialize, use, and terminate a QueryListClass object and related objects. The example plugs a QueryListClass into a BrowseClass object. The QueryListClass object solicits query criteria (search values) with a “list” dialog, then generates a filter expression based on the end user input.

PROGRAM

_ABCDllMode_ EQUATE(0)

_ABCLinkMode_ EQUATE(1)

INCLUDE('ABWINDOW.INC')

INCLUDE('ABBROWSE.INC')

INCLUDE('ABQUERY.INC')

  MAP

  END

GlobalErrors  ErrorClass

Access:Customer CLASS(FileManager)

Init             PROCEDURE

               END

Relate:Customer CLASS(RelationManager)

Init             PROCEDURE

Kill             PROCEDURE,VIRTUAL

               END

GlobalRequest  BYTE(0),THREAD

GlobalResponse BYTE(0),THREAD

VCRRequest     LONG(0),THREAD

Customer      FILE,DRIVER('TOPSPEED'),PRE(CUS),CREATE,THREAD

CustomerIDKey KEY(CUS:ID),NOCASE,OPT,PRIMARY

NameKey       KEY(CUS:LastName),NOCASE,OPT

Record         RECORD,PRE()

ID              LONG

LastName        STRING(20)

FirstName       STRING(15)

City            STRING(20)

State           STRING(2)

ZIP             STRING(10)

              END

             END

CustView VIEW(Customer)

        END

CustQ        QUEUE

CUS:LastName  LIKE(CUS:LastName)

CUS:FirstName LIKE(CUS:FirstName)

CUS:ZIP       LIKE(CUS:ZIP)

ViewPosition  STRING(1024)

            END

CusWindow WINDOW('Browse Customers'),AT(,,210,105),IMM,SYSTEM,GRAY

      LIST,AT(5,5,200,80),USE(?CusList),IMM,HVSCROLL,FROM(CustQ),|

      FORMAT('80L(2)|M~Last~@s20@64L(2)|M~First~@s15@44L(2)|M~ZIP~@s10@')

      BUTTON('&Query'),AT(50,88),USE(?Query)

      BUTTON('Close'),AT(90,88),USE(?Close)

         END

ThisWindow CLASS(WindowManager)          !declare ThisWindow object

Init        PROCEDURE(),BYTE,PROC,VIRTUAL

Kill        PROCEDURE(),BYTE,PROC,VIRTUAL

          END

Query     QueryListmClass             !declare Query object

QBEWindow QueryListVisual             !declare QBEWindow object

BRW1     CLASS(BrowseClass)            !declare BRW1 object

Q         &CustQ              

        END

CODE

GlobalErrors.Init

Relate:Customer.Init

GlobalResponse = ThisWindow.Run()         !ThisWindow handles all events

Relate:Customer.Kill

GlobalErrors.Kill

ThisWindow.Init PROCEDURE()

ReturnValue     BYTE,AUTO

CODE

ReturnValue = PARENT.Init()

IF ReturnValue THEN RETURN ReturnValue.

SELF.FirstField = ?CusList

SELF.VCRRequest &= VCRRequest

SELF.Errors &= GlobalErrors

SELF.AddItem(?Close,RequestCancelled)

Relate:Customer.Open

BRW1.Init(?CusList,CustQ.ViewPosition,CustView,CustQ,Relate:Customer,ThisWindow)

OPEN(CusWindow)

SELF.Opened=True

Query.Init(QBEWindow)                !initialize Query object

BRW1.Q &= CustQ

BRW1.AddSortOrder(,CUS:NameKey)

BRW1.AddField(CUS:LastName,BRW1.Q.CUS:LastName)

BRW1.AddField(CUS:FirstName,BRW1.Q.CUS:FirstName)

BRW1.AddField(CUS:ZIP,BRW1.Q.CUS:ZIP)

BRW1.QueryControl = ?Query            !register Query button w/ BRW1

BRW1.UpdateQuery(Query)               !make each browse item Queryable

Query.AddItem('Cus:State','State')    !make State field Queryable too

SELF.SetAlerts()

RETURN ReturnValue

ThisWindow.Kill  PROCEDURE()

ReturnValue    BYTE,AUTO

CODE

ReturnValue = PARENT.Kill()

IF ReturnValue THEN RETURN ReturnValue.

Relate:Customer.Close

RETURN ReturnValue

Access:Customer.Init PROCEDURE

CODE

PARENT.Init(Customer,GlobalErrors)

SELF.FileNameValue = 'Customer'

SELF.Buffer &= CUS:Record

SELF.Create = 1

SELF.AddKey(CUS:CustomerIDKey,'CUS:CustomerIDKey',1)

SELF.AddKey(CUS:NameKey,'CUS:NameKey',0)

Relate:Customer.Init PROCEDURE

CODE

Access:Customer.Init

PARENT.Init(Access:Customer,1)

Relate:Customer.Kill PROCEDURE

CODE

Access:Customer.Kill

PARENT.Kill

querylistclass_conceptual_example.htm.txt · Last modified: 2021/04/15 15:57 by 127.0.0.1