Numbering Objects

208 views
Skip to first unread message

evering...@gmail.com

unread,
Jan 23, 2007, 1:27:44 PM1/23/07
to MapInfo-L
Hi,

I am having trouble numbering map objects with a unique ID.
I found the post copy+pasted below on the old MapInfo-L archive, and
have already got that far, but what I'd like is to assign "2-digit"
integer numbers for each ID.

i.e. starting from 01, 02, 03, 04, 05, 06, 07, 08 ,09, 10........

At the moment I have written a MapBasic script to assign the ID
numbers. The ID column is defined as "Integer" and the results from
1-10 appear like below.

e.g. 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 .......

So when the table is sorted the objects look like.....

1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 2, 20, 21, 22, 23........

Please respond if you know a method to ensure all the ID's can be
assigned the same number of characters...

Thanks
David


Previous post below.....

-----------------------------------------------------------------------------------------------------------------------------------------------

From: on 06/29/2004 10:02 AM CET
Recipients: <mapi...@lists.directionsmag.com>
Subject: RE: MI-L numbering the objects

Abhas

I presume you mean numbering the records/rows of the table, rather than
the objects (i.e. map features). So you can update the ID column with
an
incremental variable, something like:

Dim lnID, lnRowID as INTEGER

lnID = 1
Fetch First From MyTable
Do while not EOT( MyTable)
lnRowID = RowID
Update MyTable set IDColName = lnID where RowID = lnRowID
lnID = lnID + 1
Fetch Next From MyTable
Loop

HTH

Terry McDonnell

-----Original Message-----
From: abhas [mailto:ab...@iis.u-tokyo.ac.jp]
Sent: 29 June 2004 05:16
To: Mapinfo-L
Subject: MI-L numbering the objects

Dear All,

I want to add a column to an existing table, The new column should
contain
ID number, which is to be in a sequence as per the objects in the
table.
I mean the ID's can be such as......for first object in the table ID=1,
for
second object in the table ID=2... and so on.
One way is to go to the table and add the numbers manually. But the
objects
are in a large number to be added manually.

I will be thankful if I get a simply approach to it.

looking forward for a kind reply.

with regards,
abhas
----- Original Message -----
From: "Apers Mathieu" <Mathie...@nzpost.co.nz>
To: "Mapinfo-L" <mapi...@lists.directionsmag.com>
Sent: Tuesday, June 29, 2004 5:58 AM
Subject: RE: MI-L Multiple labels for a single object


Thanks to everyone who replied.

it looks like the simplest way will be for me to duplicate the table
and
disaggregate it, which i will do

Cheers all

Mathieu Apers

-----Original Message-----
From: Uffe Kousgaard [mailto:uf...@routeware.dk]
Sent: Tuesday, 29 June 2004 1:20 AM
To: Mapinfo-L
Subject: Re: MI-L Multiple labels for a single object


From: "Jacques Paris" <jac...@paris-pc-gis.com>

> I think that you would need to build a special table just for
> labelling by exploding (disaggregating) all your regions while keeping
> real donuts as one region. (option "retain holes in regions" of the
> "objects | disaggregate" menu command" )

This function ("retain holes") was new in MapInfo 6.5. For earlier
versions you can grab a copy of our ToolBox, which will perform the
same
operation for MI 4.5 - 6.0.

Kind regards

Uffe Kousgaard
www.routeware.dk


---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: mapinfo-l-...@lists.directionsmag.com
For additional commands, e-mail: mapinfo...@lists.directionsmag.com
Message number: 12379
This email with any attachments is confidential and may be subject to
legal
privilege.
If it is not intended for you please reply immediately, destroy it and
do
not copy, disclose or use it in any way.

---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: mapinfo-l-...@lists.directionsmag.com
For additional commands, e-mail: mapinfo...@lists.directionsmag.com
Message number: 12383

__________________________________________________
Do You Yahoo!?
http://bb.yahoo.co.jp/


---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: mapinfo-l-...@lists.directionsmag.com
For additional commands, e-mail: mapinfo...@lists.directionsmag.com
Message number: 12385


---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: mapinfo-l-...@lists.directionsmag.com
For additional commands, e-mail: mapinfo...@lists.directionsmag.com
Message number: 12389

--------------------------------------------------------------------------------
[Previous Main Topic]
Thread information will be updated shortly.
[Next Main Topic]


------------------------------------------------------------------------------------------------------------------------------------------------------------

Uffe Kousgaard

unread,
Jan 23, 2007, 1:36:30 PM1/23/07
to mapi...@googlegroups.com
> The ID column is defined as "Integer" and the results from
> 1-10 appear like below.
>
> e.g. 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 .......
>
> So when the table is sorted the objects look like.....
>
> 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 2, 20, 21, 22, 23........

It looks like your field as not integer, but Char. Please check.

Regards
Uffe Kousgaard

Martin R

unread,
Jan 25, 2007, 3:37:06 PM1/25/07
to MapInfo-L
Hi David,

If you are updating a character field and you want to pad the numbers
with 0's then you could use something like:


update <mytable> set <myfield> = right$("0000"& rowid,4)

This will give you a left padded Unique ID eg 0001,0002,0003 etc which
will sort correctly.

Adjust the number of 0's and width of the string to suit.


Regards

Martin


On Jan 24, 7:27 am, "everingdavid...@gmail.com"


<everingdavid...@gmail.com> wrote:
> Hi,
>
> I am having trouble numbering map objects with a unique ID.
> I found the post copy+pasted below on the old MapInfo-L archive, and
> have already got that far, but what I'd like is to assign "2-digit"
> integer numbers for each ID.
>
> i.e. starting from 01, 02, 03, 04, 05, 06, 07, 08 ,09, 10........
>
> At the moment I have written a MapBasic script to assign the ID
> numbers. The ID column is defined as "Integer" and the results from
> 1-10 appear like below.
>
> e.g. 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 .......
>
> So when the table is sorted the objects look like.....
>
> 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 2, 20, 21, 22, 23........
>
> Please respond if you know a method to ensure all the ID's can be
> assigned the same number of characters...
>
> Thanks
> David
>
> Previous post below.....
>

> ---------------------------------------------------------------------------­--------------------------------------------------------------------

> From: "Jacques Paris" <jacq...@paris-pc-gis.com>
>
> > I think that you would need to build a special table just for
> > labelling by exploding (disaggregating) all your regions while keeping
> > real donuts as one region. (option "retain holes in regions" of the
> > "objects | disaggregate" menu command" )
>
> This function ("retain holes") was new in MapInfo 6.5. For earlier
> versions you can grab a copy of our ToolBox, which will perform the
> same
> operation for MI 4.5 - 6.0.
>
> Kind regards
>
> Uffe Kousgaardwww.routeware.dk
>
> ---------------------------------------------------------------------
> List hosting provided by Directions Magazine |www.directionsmag.com|

> To unsubscribe, e-mail: mapinfo-l-unsubscr...@lists.directionsmag.com
> For additional commands, e-mail: mapinfo-l-h...@lists.directionsmag.com


> Message number: 12379
> This email with any attachments is confidential and may be subject to
> legal
> privilege.
> If it is not intended for you please reply immediately, destroy it and
> do
> not copy, disclose or use it in any way.
>
> ---------------------------------------------------------------------
> List hosting provided by Directions Magazine |www.directionsmag.com|

> To unsubscribe, e-mail: mapinfo-l-unsubscr...@lists.directionsmag.com
> For additional commands, e-mail: mapinfo-l-h...@lists.directionsmag.com
> Message number: 12383
>
> __________________________________________________
> Do You Yahoo!?http://bb.yahoo.co.jp/


>
> ---------------------------------------------------------------------
> List hosting provided by Directions Magazine |www.directionsmag.com|

> To unsubscribe, e-mail: mapinfo-l-unsubscr...@lists.directionsmag.com
> For additional commands, e-mail: mapinfo-l-h...@lists.directionsmag.com


> Message number: 12385
>
> ---------------------------------------------------------------------
> List hosting provided by Directions Magazine |www.directionsmag.com|

> To unsubscribe, e-mail: mapinfo-l-unsubscr...@lists.directionsmag.com
> For additional commands, e-mail: mapinfo-l-h...@lists.directionsmag.com
> Message number: 12389
>
> ---------------------------------------------------------------------------­-----


> [Previous Main Topic]
> Thread information will be updated shortly.
> [Next Main Topic]
>

> ---------------------------------------------------------------------------­---------------------------------------------------------------------------­------- Hide quoted text -- Show quoted text -

Richard Greenwood

unread,
Jan 25, 2007, 11:28:56 PM1/25/07
to mapi...@googlegroups.com
On 1/25/07, Martin R <martin....@gmail.com> wrote:
>
> Hi David,
>
> If you are updating a character field and you want to pad the numbers
> with 0's then you could use something like:
>
>
> update <mytable> set <myfield> = right$("0000"& rowid,4)
>
> This will give you a left padded Unique ID eg 0001,0002,0003 etc which
> will sort correctly.

Or use format$() something like:
update SOMETABLE set SOMECOLUMN = format$(ROWID, "0000");

--
Richard Greenwood
richard....@gmail.com
www.greenwoodmap.com

evering...@gmail.com

unread,
Jan 26, 2007, 10:01:46 AM1/26/07
to MapInfo-L
Many thanks.....

Its so easy now I know how.
As usual that answer was there in front of me the whole time, but I
never saw it until you pointed it out.

Much appreciated.

On Jan 25, 11:28 pm, "Richard Greenwood" <richard.greenw...@gmail.com>
wrote:


> On 1/25/07, Martin R <martin.round...@gmail.com> wrote:
>
>
>
> > Hi David,
>
> > If you are updating a character field and you want to pad the numbers
> > with 0's then you could use something like:
>
> > update <mytable> set <myfield> = right$("0000"& rowid,4)
>
> > This will give you a left padded Unique ID eg 0001,0002,0003 etc which

> > will sort correctly.Or use format$() something like:


> update SOMETABLE set SOMECOLUMN = format$(ROWID, "0000");
>
> --
> Richard Greenwood

> richard.greenw...@gmail.comwww.greenwoodmap.com

Terry McDonnell

unread,
Jan 26, 2007, 11:37:18 AM1/26/07
to mapi...@googlegroups.com
You sure that WILL sort correctly? Numeric fields stored in character
format do not follow a numeric sequence fully. For example:
1, 12, ,13, 14, 15, 16, 17, 18, 19, 2, 20, 21, ...

Martin R

unread,
Jan 29, 2007, 4:25:58 AM1/29/07
to MapInfo-L
Hi Terry,

The numbers will be left padded with 0's so rather than being 1,2,3,4
etc they would be character values of 0001,0002,0003,0004 etc and
therefore will sort correctly so long as all the strings are the same
length

Cheers

Martin

On Jan 27, 5:37 am, "Terry McDonnell" <T...@martlet.uk.com> wrote:
> You sure that WILL sort correctly? Numeric fields stored in character
> format do not follow a numeric sequence fully. For example:
> 1, 12, ,13, 14, 15, 16, 17, 18, 19, 2, 20, 21, ...
>
> -----Original Message-----
> From: mapi...@googlegroups.com [mailto:mapi...@googlegroups.com] On
>

> Behalf Of everingdavid...@gmail.com

Terry McDonnell

unread,
Jan 29, 2007, 4:38:19 AM1/29/07
to mapi...@googlegroups.com
Hi Martin

Oh, yes, I guess you're right. I wasn't really concentrating, it was
Friday, and I guess I missed the 0 padding :-)

Cheers

Terry

Eric Johnson

unread,
Jan 29, 2007, 2:46:50 PM1/29/07
to mapi...@googlegroups.com
Has anyone ever run into the following?

Upon executing a "close all interactive" statement in a program I've
written, I get a warning message from MI that says "You cannot quit
MapInfo now."

No tables are closed.

I've been writing MB code for a number of years, and have used "close
all" frequently. I've never encountered this, though.

Any thoughts most welcome.

Cheers,

Eric Johnson
Boulder, CO

Peter Horsbøll Møller

unread,
Jan 29, 2007, 2:55:34 PM1/29/07
to mapi...@googlegroups.com
Eric,

I guess MapInfo just would like you to hang around a bit longer ;-)

You wuoldn't happen to have some other applications running, that would interfer with your Close All command ?
You could try closing down all the tool in the Tools menu and then try to Close All again.

Have you tried manually closing all ?

Peter Horsbøll Møller
GIS Developer, MTM
Geographical Information & IT

COWI A/S
Odensevej 95
DK-5260 Odense S.
Denmark

Tel +45 6311 4900
Direct +45 6311 4908
Mob +45 5156 1045
Fax +45 6311 4949
E-mail p...@cowi.dk
http://www.cowi.dk/gis

Spencer Simpson

unread,
Jan 29, 2007, 2:59:56 PM1/29/07
to mapi...@googlegroups.com
"You cannot quit MapInfo now." usually occurs when MapInfo is waiting for a
user response to one of its own message dialogs (such as the one that pops
up when a MB app crashes), so make sure there aren't any dialogs showing.

Hope this helps
Spencer

Eric Johnson

unread,
Jan 29, 2007, 4:26:22 PM1/29/07
to mapi...@googlegroups.com
I'm issuing the 'close all' when there's a custom dialog showing, as the
result of user clicking a button on the dialog. So, it's not an
MI-generated message dialog, but I'll bet it's the issue.

I can 'close all' from the MB window once the dialog is dismissed, but
can't use the MB window when there's an active dialog.

Spencer & Peter, thanks for the replies.

-- Eric

Spencer Simpson

unread,
Jan 29, 2007, 5:02:59 PM1/29/07
to mapi...@googlegroups.com
Let's assume for a moment you want to keep the "close all" while your dialog
is visible.

Try "close all" without "interactive", and see if you can close all the
tables then. You may have to write your own code to loop through all the
tables, look for unsaved edits, prompt the user whether to save the data or
not, and do the saves.

But "close all" is a big, momentous thing to do, and you may want to move
that outside the dialog, as part of the action that happens when the user
dismisses the dialog.

HTH

Eric Johnson

unread,
Jan 29, 2007, 5:14:21 PM1/29/07
to mapi...@googlegroups.com
I needed to have a button in a dialog close all open tables.  However, the Close All statement apparently can't be issued when there's an active dialog.

I found that closing individual tables is allowed, though, using the Close Table statement.

Here's what I ended up doing:
   num_tablestoclose = numtables()
   do
         nameoftabletoclose = tableinfo(1,tab_info_name)
         close table nameoftabletoclose interactive
         num_tablestoclose = numtables()
   loop while num_tablestoclose > 0
-- Eric Johnson
    Boulder, CO
Reply all
Reply to author
Forward
0 new messages