How to run a routine when a sheet is opened or sav

Bacis2 and API programming
Post Reply
drutiss
Posts: 5
Joined: Tue Apr 16, 2002 9:39 am
Location: Columbia, SC

How to run a routine when a sheet is opened or sav

Post by drutiss » Wed Aug 07, 2002 1:32 pm

Hello,

How can a bacis 2 function be called when any sheet
is opened or saved?

I suspect there should be some event functions that are triggered when a sheet is opened. A more general question might be what system events are available,
and how do you add routines for those events?

I know I've run across this in the help files, but I can't find them now.

Thanks,

Steve

geoz
Posts: 7
Joined: Mon Apr 22, 2002 3:00 pm
Location: Woodland, CA
Contact:

How to run a routine when a sheet is opened or sav

Post by geoz » Thu Aug 08, 2002 3:38 pm

I could also use this feature. I have found 3 useful ones, however.
The file shown below is called
library-init.bar
and is to be located somewhere in \UI\MED2D.
Compile it as you would any bacis2 ".bad" file and run
library_create_index()
in Bacis2. Note that it is a little different than a typical procedure file.

---------------------------------------------------------------------
proc
-- this one runs at startup
m2d_callback_set(!startup,coen_startup)

-- this one runs only when quitting Medusa
m2d_callback_set(!quit,coen_quit)

-- this one runs when selecting elements
m2d_callback_set(!select,coen_select)

endproc

---------------------------------------------------------------------
Coen_startup sets certain defaults for different users, some keyboard accelerators, etc.

Coen_quit writes out some dictionaries of the directory names used in the session, logs the time/date, etc.

Coen_select is the cool one. It displays data about the selected element(s) in the text window like Type, Layer, ID#,Text height & actual text so I don't have to zoom in just to read it. I also have it display user text attributes that we use for part numbers, item description, size, material, etc. There's no guessing about what is selected.

George

drutiss
Posts: 5
Joined: Tue Apr 16, 2002 9:39 am
Location: Columbia, SC

How to run a routine when a sheet is opened or sav

Post by drutiss » Fri Aug 09, 2002 4:47 pm

Thanks George for the post,

I tried !open, !close and a couple of other possible
symbol names without success.
I noticed the !select, runs every time something is
selected, and when a new sheet is opened.
It would be possible to write a !select function that
tests for a new sheet. This would be a possible !open
workaround, but would not work for !close.

Another possiblity would be to trap the file open functions that are built into Medusa (file open, sym/sheet preview dialogs, and others)
I redefined the !ok definition of the file open dialog,
which would capture which file was intended to be opened, then call the original function that would have been called. (mui_sheet_open_ok(object,attribute,arg)) The problem is, the user can cancel the file open, if the current sheet has not been opened.

Any other ideas?

Is there a way to list the possible symbol names for the
m2d_callback_set function that may not be documented?
How do you list what functions are to be called for a given symbol? Example: List the functions to run at
the !select event.

Thanks,

Steve

Post Reply