To add a macro to the Tools menu :
- Pull down the "Tools" menu and select the option "Modify tools". This will popup the Modify Tools dialog.
- Press the plus button to add a tool to the list.
- Fill in the description for the new tool.
- Check the "Execute script" checkbox. This will tell JoPPS it is dealing with a JoPPS-Script.
- Enter the script code in the source editbox. You can load an existing script directly from file using the "Open" speedbutton.
You can save the script pressing the "Save" speedbutton. You can edit the script in a more advanced JScripter window pressing the "J" speedbutton.
- Add a new tool or close the dialog pressing the Ok button to confirm the new tool.
To run a macro from the Tools menu :
- Pull down the "Tools" menu.
- Select the requested tool from the dropdown menu.
- The selected tool will be executed immediately. If the script execution terminates premature due to a run-time error the JScripter window opens and the cursor is positioned at the source line causing the error.
Tool macro example:
IF GetActiveProjectIndex() < 0 THEN
Fatal("No project loaded !");OldCalcMode := GetCalcMode();
Recalc := !ResultsValid();
IF OldCalcMode <> CALCMODE_PROJECT THEN
{
SetCalcMode(CALCMODE_PROJECT);
Recalc := TRUE;
};
TagReport(SLOT_ALL,FALSE);
TagReport(SLOT_BILL_OF_MATERIAL,TRUE);
IF Recalc THEN Calculate() ELSE UpdateReports();
SetCalcMode(OldCalcMode);
IF HasResult(SLOT_BILL_OF_MATERIAL) THEN
{
IF ReportInViewer() <> SLOT_BILL_OF_MATERIAL THEN
ShowResult(SLOT_BILL_OF_MATERIAL);
IF AskYN('Print result ?') THEN
PrintResult(False,0);
}
ELSE
{
Fatal("No result !");
};