Label expression concatenation issues

642 views
Skip to first unread message

MrChimp

unread,
Jul 4, 2011, 9:29:06 AM7/4/11
to MapInfo-L
(This is part question, part rant. Apologies and thanks in advance!)

I am having a massively frustrating problem with labels and
concatenation.

I have a few layers which have expressions as labels. The expressions
are fairly basic. Something like this:

var1 & " some text " & Chr$(10) & var2

At first this works fine. However when I go to edit the expression the
spaces surrounding the &s have been removed leaving this:

var1&" some text "&Chr$(10)&var2

...which is syntactically incorrect. And won't let you press ok until
you have re-entered the spaces.

The same thing happens when I save the workspace. This is even more of
a problem as it means in order to get the workspace to reopen
correctly I have to edit the .wor in a text editor and reinsert the
missing spaces. (plus the mapper location somehow resets itself to
show everything, with all layers on and displays a dialog box which,
meaning I have to wait about 15 minutes for it to render the map
before I can exit properly - or I can just ctrl+alt+del out).

This - coupled with the glitchy label editing and occasional crash
which seem to have been introduced in 10.5 - have made making maps a
real ball-ache. And considering that's all I do in MapInfo I have
started swearing more than is acceptable in an office environment.

Does anybody else have this problem? Does anybody know of a way around
this?

Warren Vick

unread,
Jul 4, 2011, 9:36:33 AM7/4/11
to mapi...@googlegroups.com
Hello Mr Chimp,

I can't see why spaces are needed in an expression like this, but try "+" instead of "&" to append your strings in the label expression.

Regards,
Warren Vick
Europa Technologies Ltd.
http://www.europa.uk.com

var1&" some text "&Chr$(10)&var2

--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en

MrChimp

unread,
Jul 4, 2011, 9:42:07 AM7/4/11
to MapInfo-L
Ah! You genius, that's done it!

Is there any other difference between & and +? I thought they were
equivalent and I've just been in the habit of using &.

Thanks!

On Jul 4, 2:36 pm, Warren Vick <wv...@europa.uk.com> wrote:
> Hello Mr Chimp,
>
> I can't see why spaces are needed in an expression like this, but try "+" instead of "&" to append your strings in the label expression.
>
> Regards,
> Warren Vick
> Europa Technologies Ltd.http://www.europa.uk.com

Warren Vick

unread,
Jul 4, 2011, 9:52:48 AM7/4/11
to mapi...@googlegroups.com
I'm not sure if they are absolutely identical. I always got the impression that "&" was favoured, but I still use "+" anyway. Confusion may occur when appending two numbers, as that will sum instead.

/W

MrChimp

unread,
Jul 4, 2011, 10:10:26 AM7/4/11
to MapInfo-L
I got that impression too, and used & so as to differentiate between
addition and concatenation. I can't find anything about it in the
documentation other than "The ampersand also performs string
concatenation." Either way, I think I'll be using + from now on.

Thanks again!

college.atlas

unread,
Jul 5, 2011, 6:06:59 AM7/5/11
to MapInfo-L
This might be 10.5 getting more SQL compliant.

In SQL & is a Bitwise AND operator.

http://msdn.microsoft.com/en-us/library/ms174965.aspx

Bill Thoen

unread,
Jul 5, 2011, 9:58:39 AM7/5/11
to mapi...@googlegroups.com
On 7/4/2011 7:42 AM, MrChimp wrote:
> Ah! You genius, that's done it!
>
> Is there any other difference between& and +? I thought they were

> equivalent and I've just been in the habit of using&.
Use '&' when concatenating a number to the string, but use a '+' when
joining a string to a string. I think this is an old VB convention. For
example:

Dim sEvent As String
sEvent = "Event: " + "the Deep Thought" + " World record time is " &
7 & " minutes " & 32.208 & " seconds."

--
*Bill Thoen*
GISnet - www.gisnet.com
303-786-9961

MrChimp

unread,
Aug 2, 2011, 9:58:02 AM8/2/11
to MapInfo-L
I've just come across this section of the user guide:

"You can use the ampersand operator (&) instead of the plus operator
when concatenating strings.
The & operator forces both operands to be strings, and then
concatenates the strings. This is
different than the + operator, which can work with numbers or dates
without forcing conversion to
strings.
"The & character is also used to specify hexadecimal numbers
(&Hnumber). When you use &
for string concatenation, make sure you put a space before and after
the & so that the
MapBasic compiler does not mistake the & for a hex number prefix."

That might have something to do with it though I don't quite
understand the distinction in the first part. How does it concatenate
them without converting them to strings first?


On Jul 5, 2:58 pm, Bill Thoen <bth...@gisnet.com> wrote:
> On 7/4/2011 7:42 AM,MrChimpwrote:> Ah! You genius, that's done it!

Richard Greenwood

unread,
Aug 2, 2011, 10:13:21 AM8/2/11
to mapi...@googlegroups.com
On Tue, Aug 2, 2011 at 7:58 AM, MrChimp <chim...@gmail.com> wrote:
> I've just come across this section of the user guide:
>
> "You can use the ampersand operator (&) instead of the plus operator
> when concatenating strings.
> The & operator forces both operands to be strings, and then
> concatenates the strings. This is
> different than the + operator, which can work with numbers or dates
> without forcing conversion to
> strings.
> "The & character is also used to specify hexadecimal numbers
> (&Hnumber). When you use &
> for string concatenation, make sure you put a space before and after
> the & so that the
> MapBasic compiler does not mistake the & for a hex number prefix."
>
> That might have something to do with it though I don't quite
> understand the distinction in the first part. How does it concatenate
> them without converting them to strings first?

In the MapBasic window:
print 1 + 1
print 1 & 1

Rich

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

MrChimp

unread,
Aug 2, 2011, 10:25:31 AM8/2/11
to MapInfo-L
*facepalm*

I need more coffee.

On Aug 2, 3:13 pm, Richard Greenwood <richard.greenw...@gmail.com>
wrote:
> richard.greenw...@gmail.comwww.greenwoodmap.com

Hutchinson, Pamela

unread,
Aug 2, 2011, 10:25:14 PM8/2/11
to mapi...@googlegroups.com

Hi I have a selected polygon from one layer and I would like to select all the point objects from another layer that fall within the selected Polygon. I'm sure there must be an easy way to do this.


PAM HUTCHINSON
Park Assets Officer
City of Wanneroo

T : 08 9405 5374
F : 08 9705 5095
E : pamela.h...@wanneroo.wa.gov.au

23 Dundebar Road, Wanneroo WA 6065
Locked Bag 1, Wanneroo WA 6946

wanneroo.wa.gov.au


City of Wanneroo Disclaimer: The material transmitted in this E-mail may contain confidential and/or privileged material and is intended only for the addressee. If you receive this in error, please notify the sender and destroy any copies of the material immediately. We believe this e-mail to be free of viruses but recommend that you confirm this before opening any attachments.

Williams, Bill (DPS)

unread,
Aug 2, 2011, 11:55:11 PM8/2/11
to mapi...@googlegroups.com
Pam
1. Boundary select tool; OR
2. Use SQL and WHERE CLAUSE : where polygon.obj contains point.obj
You'll see the OBJ reference under "COLUMNS" in the SQL select dialog box.
However, when you set up the SQL query, it should automatically recognise that the polygons contain points.
Hope this helps.


Bill Williams
Senior Researcher, Statistics & Mapping Section
Parliamentary Library
Department of Parliamentary Services
Parliament House
PO Box 6000
CANBERRA ACT 2600
Telephone : 02 62772513
Email: bill.w...@aph.gov.au

wanneroo.wa.gov.au

--

zer...@gmail.com

unread,
Aug 2, 2011, 11:55:46 PM8/2/11
to MapInfo-L
Hi,

Use "Boundary Select". It will do the job.


Regards,
Zery
Sent from my BlackBerry®
powered by Sinyal Kuat INDOSAT

-----Original Message-----
From: "Hutchinson, Pamela" <Pamela.H...@wanneroo.wa.gov.au>
Sender: mapi...@googlegroups.com
Date: Wed, 3 Aug 2011 10:25:14
To: mapi...@googlegroups.com<mapi...@googlegroups.com>
Reply-To: mapi...@googlegroups.com
Subject: [MI-L] Selecting point objects from a Selected polygon


Hutchinson, Pamela

unread,
Aug 3, 2011, 12:18:14 AM8/3/11
to mapi...@googlegroups.com
Thanks Bill I used the SQL method but found I had to save my selection before this would work. I was hoping there may me something like the location selection tool in Arcview.

If not I will survive with the SQL method


PAM HUTCHINSON
Park Assets Officer
City of Wanneroo

T   :   08 9405 5374
F   :   08 9705 5095 
E   :   pamela.h...@wanneroo.wa.gov.au

23 Dundebar Road, Wanneroo WA 6065
Locked Bag 1, Wanneroo WA 6946

wanneroo.wa.gov.au

Peter Horsbøll Møller

unread,
Aug 3, 2011, 1:29:39 AM8/3/11
to mapi...@googlegroups.com
Or use SQL Select:

Table(s): MYTABLE
Where: OBJ Within Any (Select OBJ From Selection)

Peter Horsbøll Møller
Pitney Bowes Business Insight - MapInfo


2011/8/3 <zer...@gmail.com>
Reply all
Reply to author
Forward
0 new messages