In MapBasic you can create a text object in a layout window by using the "Create text" statement. You can also use the same statement to update this object.

I am working on a tool that creates several plans by repeatedly exporting a layout window as an image file. Between each export I would like to update the text in the layout window to indicate the reference number of the site.

1 Answer
1

I have done this but as far as I know you have to select the text object using the text that is in that object. Here is some example code which finds an object by looking for the the text in the variable searchText:

To expand on this, the way I use this code is to create a text object on a layout with some standard text at the front of it (for example I place an @ symbol and a number, so on the layout the text would read "@01 Text I want in the text object"). Then I place a white rectangle object on the layout over the "@01" part of the string to hide this.

When using the above code, the searchText variable is set to "@01" and the 7th line of code finds the text object where the first 3 characters are equal to "@01". Once you have this object, it sets its new value to the searchText plus whatever you want to change the remainder of the text object to which you set in the newText variable. If you give all of the text objects on the layout different numbers, then you can refer to them uniquely by checking the first 3 characters of the string. I have edited the code a little to make it clearer.

I know its not a particularly pretty way to do it, but it does work well.

Thanks for that. I've ended up using a mix of your code and Peter's code from here: groups.google.com/group/mapinfo-l/browse_thread/thread/…. Peter's idea of storing the RowID makes changing the text repeatedly a bit easier. Saves searching through tables each time. Others may have an issue of the RowIds changing if other objects are added/removed from the layout but for my purposes this is not an issue.
–
Mr_ChimpJun 29 '11 at 10:18