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

1 Answer 1


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.


  • Thanks James. When you put it like that it seems so obvious!
    – Mr_Chimp
    Commented Sep 29, 2010 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
    Commented Sep 29, 2010 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
    Commented Sep 29, 2010 at 14:36
  • Yeah try and cross post to here as well, we need as much traffic here as we can.
    – Nathan W
    Commented Sep 30, 2010 at 12:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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