Clearing cosmetic layers while saving valid map edits

459 views
Skip to first unread message

David Reid

unread,
Jul 30, 2009, 10:25:19 AM7/30/09
to mapi...@googlegroups.com

Greetings all,

I'm having a major malfunction this morning trying to wrap my head around
this task.

I have an mbx that has opened a couple mapper windows, and a couple browser
windows.

Either or both mapper windows may have "junk" in the cosmetic layer which I
know is safe to discard.

When I terminate this app, I wish to 'Close All' windows, discarding the
junk in the cosmetic layers, but saving any valid map edits if there are any
pending which I haven't noticed.

I thought I'd accomplish this with a "Commit All" type of statement, then
issue the "Close All" command without the "Interactive" statement... But
this approach seems a bit too simplistic... 'cause this dog just won't hunt!

Any help toward a solution would be greatly appreciated.

David Reid


Driver, Greg 9434

unread,
Jul 30, 2009, 11:27:42 AM7/30/09
to mapi...@googlegroups.com
David,

Before terminating the app, could you include some code to clear the cosmetic layer? You'd just need to find the name of the cosmetic layer for each map window and then use RollBack Table:

For x=1 to NumWindows()
If WindowInfo(x, WIN_INFO_TYPE) = WIN_MAPPER Then
sCosName = WindowInfo(x, WIN_INFO_TABLE)
RollBack Table sCosName
end If
Next

You could also test to see if any tables had outstanding edits that need to be saved:

For x=1 to NumTables()
If TableInfo(x, TAB_INFO_EDITED) Then ' true so save edits
Commit Table TableInfo(x, TAB_INFO_NAME)
End If
Next

You can then issue a 'close all' knowing that any cosmetic layers are empty and all edits have been saved.

There's also an option under Options -> Preferences -> Map Window - Edit where you have 3 options to 'warn prior to loss of:', one of which is the cosmetic layer. If this is unchecked and you issue a 'close all', then any objects on the cosmetic layer will not be saved, though I'm not sure if you can check/uncheck this via MapBasic.

HTH

Greg Driver

System Administrator
Applications Support
ICT
Surrey Police
NOT PROTECTIVELY MARKED
Information about this E-mail
This email and any files or attachments with it are intended solely for the use of the individual(s) or organisation(s) to whom it is addressed.
It may contain information that is confidential or subject to legal and/or professional privilege.
If you have received this email in error please notify the sender and delete it including any files or attachments from your e-mail account or computer.
Any opinions expressed in this email are those of the individual and not necessarily those of Surrey Police.
Surrey Police monitor incoming and outgoing e-mail.

David Reid

unread,
Jul 30, 2009, 1:25:56 PM7/30/09
to mapi...@googlegroups.com

Greg! Thanks immensely! Works like a charm! (the Mapbasic scripting that
is). I didn't want to set the parameter in MI's Options>Preferences menu as
this for now is more-less a specialized in-house application, when not
running it, I may want to be prompted to save Cosmetic objects.

I utilized both functions, even though the "Close All" statement could work
as it causes MI to ignore cosmetic objects, "Close All Interactive" on the
other hand would prompt for saving cosmetic objects.

Thanks again!

David
Reply all
Reply to author
Forward
0 new messages