; ------------------------------------------------------------------------------------------------

PRO db_tools::set_uvalue_connect_local, val

;   SET_UVALUE
;
;   Allows the object to store a user value.  After a new user value is stored,
;   the user value will be deleted.  This method duplicates the equivalent
;   behavior in widgests.
;
; Syntax      : 0->SET_UVALUE, val
;
; Inputs      : val = The new user value to store in the object.
;
; Opt. Inputs : None.
;
; Outputs     : None.
;
; Opt. Outputs: None.
;
; Keywords    : None.
;
; Restrictions: None.

; Free the old uval.  We won't need it anymore

PTR_FREE, self.uval

; Create the new uval.

self.uval = PTR_NEW (val)

END

; ------------------------------------------------------------------------------------------------

FUNCTION db_tools_connect_local::get_uvalue

;   GET_UVALUE
;
;   Returns the user value stored in the object.
;
; Syntax      : result = 0->GET_UVALUE ()
;
; Inputs      : None.
;
; Opt. Inputs : None.
;
; Outputs     : None.
;
; Opt. Outputs: None.
;
; Keywords    : None.
;
; Return Value: The user value stored in the object.
;
; Restrictions: None.

; Just return whatever uval points to.

RETURN, *self.uval

END

; ------------------------------------------------------------------------------------------------

FUNCTION db_tools_connect_local::getmsg

;   GETMSG
;
;   Get the last error or other informational message generated by the object.
;
; Syntax      : result = 0->GETMSG ()
;
; Inputs      : None.
;
; Opt. Inputs : None.
;
; Outputs     : None.
;
; Opt. Outputs: None.
;
; Keywords    : None.
;
; Return Value: The last message generated by the object.
;
; Restrictions: None.


; Just return whatever the current message is.

RETURN, self.msg

END


; ------------------------------------------------------------------------------------------------

FUNCTION db_tools_connect_local::init, UVALUE = uvalue

;               INIT
;
;               Perform object initialization.
;
; Inputs      : None.
;
; Opt. Inputs : None.
;
; Outputs     : None.
;
; Opt. Outputs: None.
;
; Keywords    : UVALUE  = If pased then the value this keyword is set to will be
;                         the user value of the object.  A new user value may be
;                         set by calling the method set_uval.
;
; Return Value: 1 (object initialization success).
;
; Restrictions: None.


; Set the uval, if specified

IF N_ELEMENTS (uvalue) NE 0 THEN BEGIN

  self.uval = PTR_NEW (uvalue)

ENDIF

RETURN, 1

END

; ------------------------------------------------------------------------------------------------

PRO db_tools_connect_local::cleanup

;   CLEANUP
;
;   Perform whatever operations are necessary prior to object destruction.
;
; Inputs      : None.
;
; Opt. Inputs : None.
;
; Outputs     : None.
;
; Opt. Outputs: None.
;
; Keywords    : None.
;
; Restrictions: None.

; Free any lingering heap variables.

PTR_FREE, self.uval

RETURN

END

; ------------------------------------------------------------------------------------------------

PRO db_tools_connect_local::open, dbase

; Open the requested database.

DBOPEN, dbase

RETURN

END

; ------------------------------------------------------------------------------------------------

PRO db_tools_connect_local::close

; Close the database

DBCLOSE, dbase

RETURN

END

; ------------------------------------------------------------------------------------------------

FUNCTION db_tools_connect_local::find, search, ERRMSG = msg, COUNT = count

; Find the indexes of all the records in the database that match the search
; criterion

msg = ""

found = DBFIND (search, /SILENT, ERRMSG = msg, COUNT = count)

RETURN, found

END

; ------------------------------------------------------------------------------------------------

PRO db_tools_connect_local__define

obj = { DB_TOOLS_CONNECT_LOCAL,            $ ; The object class name.
        uval:            PTR_NEW (),       $ ; User value.
        msg:             ""                $ ; Error or information message.
      }

END