Is there a function to get the layer number from the layer name in MapBasic? I am writing a script to loop through each layer I have and apply styles and labelling. Each layer is named _#_LINE or _#_BUFFER

So I was thinking of assigning the layer number as an integer, applying the styles then incrementing the # by one so it moves onto the next layer.

1 Answer 1


You can use LayerInfo to get from a layer name to the matching layer number and vice versa.


Also note that you can use a layer number to change the styling of a layer. You don't need the name.

The layer number is unique where you can have multiple layers with the same name (if you have a table in the map multiple times).

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.