Hi Brad,
I think I understand what you mean. I myself learned to a) never
write a script that works with two table occurrences at once and b)
group scripts by the table occurrence they operate with. To work with
related records I normally establish a found set and then ‘ask’ as
script from the appropriate group to do something with that found
set. That is if I have Invoice and Invoice Lines and want to, say,
print an invoice (which I do from Invoice Lines), my scripts look
like that:
Invoice: print
--------------
Perform Script[ - Begin script ]
#
Perform Script[ - Invoice: isolate invoice lines ]
Perform Script[ - Found invoice lines: print as invoice ]
#
Perform Script[ - End script ]
- Invoice: isolate invoice lines
--------------------------------
Go to Related Record[ Invoice Line, Show, Using layout: Invoice Line ]
Go to Layout[ original layout ]
Note that this script, which belongs to the Invoice table,
temporarily leaves whatever Invoice layout it happens to be on, but
immediately returns back to it. This is the main principle of all
inter-table scripts: they change layouts as necessary, but when they
ready, they return back to the original layout. In this case the
script purpose is to isolate all related records and it's completed
with one step, so it returns immediately. Sometimes it takes a bit
longer:
- Found invoice lines: print as invoice
---------------------------------------
Go to Layout[ Invoice Line: Invoice ]
#
Page Setup[ Restore, No dialog ]
Print[ Restore ]
#
Go to Layout[ original layout ]
The idea is that when I write a script and call a subscript, I'm sure
that after it returns, the main script stays on the same layout. So
in most scripts I need to get to the correct layout once, maybe in
the beginning and then no matter how many subscripts I call, I know
the layout stays same.
Some scripts are exceptions, of course, e.g. navigation scripts that
are meant to change layouts, but their actions are mostly evident and
they are mostly called in the end of the script.
The ‘- Begin script’ subscript includes the Freeze Window[] script
step, so all the layout changes are not noticeable. Only if I open
new windows in the process I need to worry about which layout I'm on;
otherwise I can do nearly everything (including custom dialogs, mode
changes, AppleScript, etc.) and be sure the only thing the user sees
is the original layout.
Take care,
--
Mikhail Edoshin
Information Analyst
Skeleton Key
[EMAIL PROTECTED]