Home > Archive > Programming with dBASE > October 2005 > OOP end of file test









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author OOP end of file test
Dan Anderson

2005-10-27, 7:28 am

How do I test for no match in a search in OOP? Here's what didn't work.
This results in an error saying the variable "eof" is undefined.


function PUSHBUTTON_GO_onClic
k
form.mousepointer = 11 // hour glass
//-- perform search
LOCAL cSearch
cSearch=UPPER(form. ENTRYFIELD_PROSP_SEA
RCH.value)
IF NOT ISBLANK(form. ENTRYFIELD_PROSP_SEA
RCH.value)
form.rowset.first()
form.rowset.refresh()
form.rowset.beginLocate()
form.rowset.applyLocate("REC = '" +cSearch+"'")

//-- test for no match
IF form.prosp1.rowset.eof()
//-- ask user if they want to try again
searchresult = MSGBOX("The end of file has been reached without
a match. Do you want to try again?","SEARCH RESULT",64+5)
IF searchresult = 6 //-- yes
form. entryfield_prosp_sea
rch.value = ""
form. entryfield_prosp_sea
rch.setfocus()
//-- change mouse pointer
form.mousepointer = 1 // pointer
return
ELSE //-- no
form.pageno = 1
//-- change mouse pointer
form.mousepointer = 1 // pointer
return
ENDIF
ENDIF

form.pushbutton_transfer.enabled = true

//-- populate controls
form.entryfield25.dataLink = form.prosp1.rowset.fields["rec"]
form.entryfield26.dataLink = form.prosp1.rowset.fields["name"]
form.entryfield27.dataLink = form.prosp1.rowset.fields["street"]
form.entryfield28.dataLink = form.prosp1.rowset.fields["city"]
form.entryfield29.dataLink = form.prosp1.rowset.fields["st"]
form.entryfield30.dataLink = form.prosp1.rowset.fields["zip"]
form.entryfield31.dataLink = form.prosp1.rowset.fields["pr"]
form.entryfield32.dataLink = form.prosp1.rowset.fields["hdg"]
form.entryfield33.dataLink = form.prosp1.rowset.fields["code"]
form.entryfield34.dataLink = form.prosp1.rowset.fields["phb"]
form.entryfield35.dataLink = form.prosp1.rowset.fields["phf"]
//-- refresh data
form.rowset.refreshControls()
ENDIF

//-- change mouse pointer
form.mousepointer = 1 // pointer
return

--
Dan Anderson
UBI Processing Dept.
andersond@ubinc.com
800-444-4824 ext 101


Ken Mayer [dBVIPS]

2005-10-27, 7:28 am

Dan Anderson wrote:
> How do I test for no match in a search in OOP? Here's what didn't work.
> This results in an error saying the variable "eof" is undefined.
>
> IF form.prosp1.rowset.eof()


IF form.prosp1.rowset.endOfSet

Ken

--
/(Opinions expressed are purely my own, not those of dataBased
Intelligence, Inc.)/

*Ken Mayer* [dBVIPS]
/Golden Stag Productions/
dBASE at goldenstag dot net
http://www.goldenstag.net/GSP
http://www.goldenstag.net/dbase
Todd Kreuter

2005-10-27, 7:28 am



Dan Anderson wrote:
>
> How do I test for no match in a search in OOP? Here's what didn't work.
> This results in an error saying the variable "eof" is undefined.
>
> function PUSHBUTTON_GO_onClic
k
> form.mousepointer = 11 // hour glass
> //-- perform search
> LOCAL cSearch
> cSearch=UPPER(form. ENTRYFIELD_PROSP_SEA
RCH.value)
> IF NOT ISBLANK(form. ENTRYFIELD_PROSP_SEA
RCH.value)
> form.rowset.first()
> form.rowset.refresh()
> form.rowset.beginLocate()
> form.rowset.applyLocate("REC = '" +cSearch+"'")


ApplyLocate will return true or false depending on the success of the
search. You don't need beginLocate() when supplying the parameters for
applyLocate. I like to bookmark my position before attempting a search,
that way you can return upon a failed search (and use the rowsets
notifyControls to turn off the visual effects of a failed search).

bm = form.rowset.bookmark()

form.rowset.notifyControls := false

if NOT form.rowset.applyLocate("Field1 = 'Something'")
// failed search
form.rowset.goto(bm)
endif

form.rowset.notifiyControls := true
form.rowset.next(0)


--
Todd Kreuter [dBVIPS]
Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com