Continue to Site

Welcome to MCAD Central

Join our MCAD Central community forums, the largest resource for MCAD (Mechanical Computer-Aided Design) professionals, including files, forums, jobs, articles, calendar, and more.

Scripting Questions

JamesM

New member
I've been writing a script for generating sequential part numbers, and have run into some odd things that some here may have encountered. I should note that I'm a novice at Java. This is based on a JFrame with a few drop-down boxes and text entry boxes followed by a button to start the process.





My first question: when recording a script a run() function and run0() function are created, and the run() calls the run0(). Is there a rule that says the run0() will only start from the run() function? I've tried to change that, mainly due to the event that controls the start button, butthe IL. commands will onlywork if the run0() function is called from run().


Second question: does anyone know of a clean way to exit or cancel from a JFrame in an Intralink script? Using system.exit closes all Intralink windows, not just the script dialog. Using the hide or dispose functions close the dialog but lock up the script. I need a way to let the user exit without running through the script via the "Done" button.


Third question: has anyone had a script that runs fine from the Scripting Options window but not when it is run through the Custom menu in Intralink? My script, when run through the Custom menu, works well half the time but the rest of the time, when started, acts like the "Done" button has already been pressed.


At least two of these problems could be eliminated if Iused the JOptionPane.showInputDialog instead of the JFrame but I wanted all the options in a single dialog box instead of several. Any suggestions?
 
Intralink looks for method run() as the entry point. The purpose of run0()
is strictly for recording purposes only and is not a required method for
execution. If you were to record hundreds of actions, you would see run1(),
run2(), run3() methods get created. There is no reason to keep any recorded
method other than run().


It sounds as if you are implying that using a JOptionPane prohibits you from
using multiple fields and/or buttons in your dialog. This is not true.


The JOptionPane is actually very flexible. For the show*Dialog methods, where
you see the "Object message" argument, you can use any GUI component or
even an array of GUI components. The layout may not be very flexible if you're
not including a JFrame, but you can make something that looks OK with very
little coding. Just build an Object[] array of JLabel's and JTextField's, then
feed that to you JOptionPane call.


If you still need more flexibility, you can embed a JOptionPane in a JDialog,
while still having blocking (or modal) behavior. This is just one example of
many things you can try.
 
You're right - I was making a false assumption about the JOptionPane. I'm starting to figure out how to do the things you mention, and am surprised at its abilities. Thanks for the great advice.
 

Sponsor

Articles From 3DCAD World

Back
Top