home *** CD-ROM | disk | FTP | other *** search
- on dbfind me, afield, operator, criteria
- global database, table, dbinstance, tableinstance, totnumrecs, listfields
- if objectp(tableinstance) = 1 then
- mSetIndex(tableinstance, "primeidx")
- mSelect(tableinstance)
- mSetCriteria(tableinstance, afield, operator, criteria)
- mSelect(tableinstance)
- set howmanyselected to mSelectCount(tableinstance)
- mGoFirst(tableinstance)
- set foundlist to list()
- repeat with i = 1 to howmanyselected
- append(foundlist, mGetField(tableinstance, afield))
- if i < (mSelectCount(tableinstance) + 1) then
- mGoNext(tableinstance)
- next repeat
- end if
- exit repeat
- end repeat
- else
- put "no tableinstance object found"
- end if
- mSetIndex(tableinstance, "primeidx")
- mSelect(tableinstance)
- return foundlist
- end
-
- on dbclosesession me
- global database, table, dbinstance, tableinstance, totnumrecs, listfields
- if objectp(table) = 1 then
- put "object table exists"
- set table to EMPTY
- put "table object instance now = " & objectp(table)
- else
- put "no object found"
- end if
- if objectp(database) = 1 then
- put "object table exists"
- set database to EMPTY
- put "database object instance now = " & objectp(database)
- else
- put "no object found"
- end if
- if objectp(tableinstance) = 1 then
- put "object tableinstance exists"
- set tableinstance to EMPTY
- put "tableinstance object instance now = " & objectp(tableinstance)
- else
- put "no object found"
- end if
- if objectp(dbinstance) = 1 then
- put "object table exists"
- set dbinstance to EMPTY
- put "dbinstance object instance now = " & objectp(dbinstance)
- else
- put "no object found"
- end if
- updateStage()
- end
-
- on dbgo me, whichrecord
- global database, table, dbinstance, tableinstance, totnumrecs, listfields
- if objectp(tableinstance) = 1 then
- mSetIndex(tableinstance, "primeidx")
- mSelect(tableinstance)
- if value(whichrecord) <= totnumrecs then
- mGo(tableinstance, whichrecord)
- else
- put "maximum record encountered at " & totnumrecs
- mGo(tableinstance, totnumrecs)
- end if
- else
- put "no tableinstance object found"
- end if
- end
-
- on dbcount me
- global database, table, dbinstance, tableinstance
- set totnumrecs to 0
- if objectp(tableinstance) = 1 then
- mSetIndex(tableinstance, "primeidx")
- mSelect(tableinstance)
- set totnumrecs to mSelectCount(tableinstance)
- else
- put "no tableinstance object found"
- end if
- return totnumrecs
- end
-
- on dblistfields me, table
- global database, table, dbinstance, tableinstance
- set listfields to list()
- if objectp(dbinstance) = 1 then
- set layout to mDumpStructure(dbinstance)
- set lineCount to the number of lines in layout
- repeat with i = 1 to lineCount
- if line i of layout contains "-field" then
- set thisfieldname to EMPTY
- repeat with j = 1 to the number of chars in line i of layout
- if charToNum(char j of line i of layout) = 39 then
- set characternumber to j
- exit repeat
- end if
- end repeat
- repeat with k = characternumber + 1 to the number of chars in line i of layout
- if charToNum(char k of line i of layout) <> 39 then
- set thisfieldname to thisfieldname & char k of line i of layout
- next repeat
- end if
- exit repeat
- end repeat
- append(listfields, thisfieldname)
- end if
- end repeat
- else
- put "dbinstance object does not exist"
- end if
- return listfields
- end
-
- on dbnext me
- global database, table, dbinstance, tableinstance, totnumrecs, listfields
- if objectp(tableinstance) = 1 then
- mGoNext(tableinstance)
- else
- put "tableinstance object does not exist"
- end if
- end
-
- on dbgetfield me, fieldName
- global database, table, dbinstance, tableinstance, totnumrecs, listfields
- set fieldcontent to EMPTY
- repeat with i = 1 to count(listfields)
- if getAt(listfields, i) = fieldName then
- if objectp(tableinstance) = 1 then
- set fieldcontent to mGetField(tableinstance, fieldName)
- next repeat
- end if
- put "tableinstance object does not exist"
- end if
- end repeat
- return fieldcontent
- end
-
- on dbopensession me
- global database, table, dbinstance, tableinstance, totnumrecs, listfields
- if (objectp(database) <> 1) and (objectp(table) <> 1) then
- set database to xtra("v12dbe")
- put database
- set table to xtra("v12table")
- put table
- else
- put "objects already exist" & database & table
- return 0
- end if
- updateStage()
- end
-
- on dbuse me, dbName, thepassword, tableName
- global database, table, dbinstance, tableinstance, totnumrecs, listfields
- if (objectp(database) = 1) and (objectp(dbinstance) <> 1) then
- set dbinstance to new(database, the pathName & dbName, "readonly", thepassword)
- put dbinstance
- end if
- if (objectp(table) = 1) and (objectp(tableinstance) <> 1) then
- set tableinstance to new(table, mGetRef(dbinstance), tableName)
- put tableinstance
- end if
- if objectp(dbinstance) = 1 then
- set totnumrecs to dbcount(me)
- set listfields to dblistfields(me, dbName)
- end if
- end
-
- on dbprevious me
- global database, table, dbinstance, tableinstance, totnumrecs, listfields
- if objectp(tableinstance) = 1 then
- mGoPrevious(tableinstance)
- else
- put "tableinstance object does not exist"
- end if
- end
-
- on dbselectall me
- global database, table, dbinstance, tableinstance, totnumrecs, listfields
- if objectp(tableinstance) = 1 then
- mSetIndex(tableinstance, "primeidx")
- mSelect(tableinstance)
- else
- put "tableinstance object does not exist"
- end if
- end
-