I could not resist reproducing below a short extract of "My Bag o'Tricks"
(it will be soon available again on our site but as a pdf file) where I
dabble with column width control. May be someone could find new "tricks" to
add to that.

For ex., the width is defined by the length of the title itself if the
contents of the column is "smaller" than the title. Adding ____'s to the
title (via modify structure) will increase the column width.

[   place holder for your contribution   ]



Have fun

Jacques Paris

e-mail                alternate
     [EMAIL PROTECTED]   [EMAIL PROTECTED]

paris PC Consult (mainly MapInfo app.)
     www.total.net/~rparis/gisproducts.htm

=======beginning of excerpt

4 - There is no way to specify column width in an explicit way.

Column width is determined internally by MI according to certain rules that
are not that obvious. For example, the computation in number of screen units
is the product of the number of characters by a certain average width (it
depends then on the character set that is used); it can be changed by Menu
Options > Text Style while the Browser is active, or by adding immediately
after the block "Browse" the following line

Set Window FrontWindow() Font ("Courier New",512,8,0)

N.B.   Be careful in writing the name of the font : this argument is case
sensitive and the spelling must conform to what is shown in the Windows font
requester.

As the column headings are displayed in bold, titles may be truncated even
if the columns are defined for the proper numbers of characters. Bold
characters are wider than plain ones, except with fixed width fonts such as
Courier.

Some display options may influence the number of characters used to define a
column width, but there are inconsistencies that prevent reliable
predictions in that area. The option of separating thousands by commas or
spaces or not at all that can be defined outside MI (The Windows 3.+ Control
panel / International / List Separator) has no effect on the way numbers are
displayed in the browser, whereas choices made for the date format defined
in the same manner as the thousands separator are respected.

The only column type that can be somewhat controlled is "character". The
column width is defined as the larger of the width in number of characters
defined in the table structure and the number of characters in the original
column name (with a maxi of 31). Giving a shorter name by an alias has no
impact; one must act directly on the table structure definitions.

A temporary column is completely out of control. Changing the nature of its
contents (e.g. STR$ of a numerical variable) or playing with string
functions (e.g. LEFT$..) results in a character column with a width in the
order of 50 spaces. Temporary columns should be transformed into permanent
features to allow any kind of positive control.

A way of building numerical columns with a specific look is to create a new
column and update it with the required expression. If colx is an integer
column and that a right-aligned 8 digit column is desired, the following
expression can do the trick :

SPACE$(8-LEN(STR$(colx))) + STR$(colx)

If numbers exceed 8 digits, there is no trap to prevent strange results.
Remember that this column will not be updated automatically if changes are
made to the contents of colx. Besides, numbers will be proper aligned on the
right only if a fixed width font is used.



6 - 5  An application


ZT_999.tab contains 3 columns, ZT, AREA, PERIMETER. It is open.

The browser should display ZT and the contents of AREA right adjusted with 4
decimal digits

1 - Modify table structure to add a new field SURF as character with a width
of 9
The width is obtained the following way : 4 decimal digits, + 1 for decimal
point + 3 (observed maximum of AREA is 324.4...) + 1 (do not ask me why)

2 - In the MapBasic window, write and run

Browse ZT, SURF "     AREA" from ZT_999
Update ZT_999 set SURF =
   Space$(4 - len(str$(int(AREA)))) + left$(str$(AREA)+"0000", len
(str$(AREA)+4))
Set Window FrontWindow() Font ("Courrier New",512,8,0)

explanations :

- an alias is used to specify column heading; here AREA is preceded by 5
blanks to form a string of 9 characters (= column width)

- Space$ pads the beginning of the SURF string with a number of spaces
dependent upon the number of digits before the decimal point

- the rest of the string is made of the significant and decimal digits,
including trailing zeroes that are added to pack the rest of the space if
there are less than 4 decimal digits.

----------------------------------------------------------------------
To unsubscribe from this list, send e-mail to [EMAIL PROTECTED] and put
"unsubscribe MAPINFO-L" in the message body, or contact [EMAIL PROTECTED]

Reply via email to