Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am trying to write a MapBasic function to check whether or not an object can be used with the Overlap/AreaOverlap functions - I need to tell whether it's a closed shape or a line/arc/point/text object.

I have two questions.

  1. Is there an existing function that will do this?

  2. Why doesn't this work?

    Function IsObjectRegion(ObjAlias As Alias) As Logical
        Dim ObjectType As SmallInt
        Note OBJ_TYPE_POINT    ' This popup is displayed correctly
        Note "Crash Now."      ' This doesn't display. 
                               ' Instead you get an error that says "could not convert data".
        ObjectType = ObjectInfo(ObjAlias, OBJ_INFO_TYPE)
        Do Case ObjectType
            Case OBJ_TYPE_REGION
                IsObjectRegion = True
                print "Object WAS a region"
            Case OBJ_TYPE_RECT 
                IsObjectRegion = True
                print "Object WAS a region"
            Case OBJ_TYPE_ROUNDRECT 
                IsObjectRegion = True
                print "Object WAS a region"
            Case OBJ_TYPE_ELLIPSE
                IsObjectRegion = True
                print "Object WAS a region"
            Case Else
                IsObjectRegion = False
                print "Object was NOT a region"
        End Case
    End Function
share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

I think you need to be passing an object variable into the function, not an alias which is just a column reference.

Function IsObjectRegion(selObj As Object) As Logical
Dim ObjectType As SmallInt

ObjectType = ObjectInfo(selObj, OBJ_INFO_TYPE)
Do Case ObjectType

If you wanted to test this out with the currently selected object, you could call the function like this:

    Dim test As Logical
    Dim testObject As Object
    testObject = Selection.Obj
    test = IsObjectRegion(testObject)

    Note test

This should return True/False.


share|improve this answer
Thanks James. When you put it like that it seems so obvious! –  Mr_Chimp Sep 29 '10 at 11:52
A good place to post about MapInfo problems is the MapInfo-L. Very helpful people who know a lot about MapInfo and MapBasic. The address is groups.google.com/group/mapinfo-l –  James S Sep 29 '10 at 13:04
Yeah, I've posted there before and pretty much always got a good answer. I've only just found out about this site though after using StackOverflow for ages, so I thought I'd give it a go. Looking good so far! –  Mr_Chimp Sep 29 '10 at 14:36
Yeah try and cross post to here as well, we need as much traffic here as we can. –  Nathan W Sep 30 '10 at 12:25
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.