Purpose |
Finds if a table needs packing
|
Author | Date of code (original) | Updated on | Date of page (original) | Updated on |
Jacques Paris jakes.paris@sympatico.ca |
11Feb2001
|
|
18Feb2001
|
|
Restrictions on use |
This module is distributed under the terms of the Lesser GNU General Public License. Restrictions on the use of this work in a commercial application or derivative work is described in the Lesser GNU General Public License page at: http://www.fsf.org/copyleft/lesser.html
|
Description |
Uses the total number of rows, the number of rows containing tabular data and the number of objects (mappable tables) of an open table to find if it requires packing. Reports the findings in clear terms including if there are records without object in a mappable table. Works on mappable and tabular only tables.
|
External resources |
|
Declare statement of sub_function. Include in your program. Copy/Paste if needed. |
declare function TabNeedPack ( tabname as string 'name of an open table ) as smallint |
Returned value(s) (function only) |
0 trouble with tabname 1 no packing required 2 some records are without object 3 some records have been deleted 4 both 2 and 3 |
Other required declare statement(s). Include in your program. Copy/Paste if needed. |
MapBasic Code. Copy/Paste if needed.
|
include "mapbasic.def" function TabNeedPack(tabname as string) as smallint dim ir as smallint dim nr,nt,no as integer dim mapp as logical onerror goto erro mapp= TableInfo(tabname,TAB_INFO_MAPPABLE) nr=tableinfo(tabname,TAB_INFO_NROWS) select * from tabname where val(str$(col1))>=0 nt=selectioninfo(SEL_INFO_NROWS) if mapp then select * from tabname where obj no=selectioninfo(SEL_INFO_NROWS) end if run menu command 304 if nr=nt then ir=1 if mapp and nt>no then ir=ir+1 end if else ir=3 if mapp and nt>no then ir=ir+1 end if end if tabneedpack=ir ' start optional segment ' printing within the function allows printing the numbers of records involved do case ir case 1 note tabname + " does not require packing" case 2 note tabname + " contains "+str$(nt-no)+" records without object" case 3 note tabname + " requires packing (there are "+str$(nr-nt)+" deleted records)" case 4 note tabname + " requires packing (there are "+str$(nr-nt)+" deleted records)" + chr$(10)+ " and contains "+str$(nt-no)+" records without object" end case ' end optional segment exit function erro: tabneedpack=0 end function |
Availability for download |
Tables.zip |
Example |
include "mapbasic.def" declare sub main declare function TabNeedPack(tabname as string) as smallint declare function SelOpenTab(byval mappabl as logical) as string '===================================================== sub main dim nametab as string dim result as smallint dim mapp as logical mapp=ask("Select only among mappable tables?","Yes","No") nametab=SelOpenTab(mapp) if nametab="" then exit sub end if result=TabNeedPack(nametab) do case result case 1 note nametab + " does not require packing" case 2 note nametab + " contains records without object" case 3 note nametab + " requires packing (there are deleted records)" case 4 note nametab + " requires packing (there are deleted records)" +chr$(10)+ " and contains records without object" case else note"Some trouble was encountered dealing with "+nametab end case end sub |
Comments |
This example calls also on the SelOpenTab() function
|
See also |