The embeded JoPPS-Script interpreter in JoPPS extends the basic JoPPS-Script syntax with specific functions, constants and objects to control different parts of JoPPS : the JoPPS-Script macro language. This macro language is intended to automate calculations, access the JoPPS database and manipulate the the project data model. Before explaining how to create macro's in JoPPS we will first discuss some concepts and terminology related to the JoPPS program itself.
Macro (or script)
A JoPPS macro is a "JoPPS-Script" script using JoPPS functions written to automate specific repetitive tasks in JoPPS. Besides stand-alone macro scripts there are two kind of macro's in JoPPS: Tool macro's and report macro's.
Single commands can be given directly from anywhere within JoPPS using the JoPPS instruction window. (pressing [CTRL][SPACE] pops up the console window)
The messagepane
The JoPPS messagepane is the region of the JoPPS main window where messages are displayed. A message consists of the message text (string) and an optional errorcode. If the errorcode for a message in the messagepane is non-zero its is assumed to be an errormessage. You can output a message to the messagepane calling the the function OutputMsg.
Related functions :
ClearMsgPane
|
Clear all messages in the messagepane. If the messagepane is currently open it will remain open.
|
CloseMsgPane
|
Closes the messagepane window.
|
MsgPaneCount
|
Returns the total number of messages in the messagepane.
|
MsgPaneErrCount
|
Returns the number of messages in the messagepane having an errorcode set. (different from zero)
|
MsgPaneGet
|
Get the message string from a message in the messagepane.
|
MsgPaneGetErrCode
|
Get a specific errorcode from a message in the messagepane.
|
MsgPaneIsOpen
|
Returns TRUE when the messagepane window is currently open.
|
OutputMsg
|
Outputs a message (or errormessage) to the messagepane.
|
Exapmle:
/* Controleer of er fouten op kleur of lengte zijn geweest, zoja melding + stoppen */
nLijnen := JOPPS.MsgPaneCount ();
nFouten := JoPPS.MsgPaneErrCount ();
If nFouten > 0 Then
{
teller := 0;
While teller < nLijnen do
{
foutCode := JoPPS.MsgPaneGetErrCode(teller);
If foutCode = -10431 || foutCode = -10432 || foutCode = -10367 Then
{
msg := "*********************** FOUT ***********************"+CRLF;
msg := msg+"Rapport geannuleerd."+CRLF+"CSF-file werd NIET aangemaakt."+CRLF;
msg := msg+"Fouten op kleur en/of lengte moeten eerst opgelost worden."+CRLF+CRLF;
msg := msg+"********** ZIE ADMINISTRATOR VOOR MEER INFO **********";
MsgBox(msg);
halt;
/* -10431 FOUTCODE BESTELCODE KLEUR PROFIEL */
/* -10432 FOUTCODE BESTELCODE KLEUR BESLAG */
/* -10367 FOUTCODE OP STANDAARD LENGTE */
};
teller := teller+1;
};
};
A project
Represents an open project in JoPPS. Open projects are kept and maintained in the JoPPS projectpool. A project contains a single projectdata object which in turn holds all the project assemblies. A simple way to add a new assembly to the current project is by using the function AddAssembly.
The function AddFramePart can be used to add extra frameparts to the current assembly.A newly added assembly becomes automatically the new current assembly and will be shown directly into the JoPPS editor.
Use the projectpool to work with open projects. The following figure illustrates the structure of a JoPPS project:
Project
|
ProjectData
|
|
Assembly 1
|
|
Framepart 1
|
|
FrameElement1
|
|
FrameElement2
|
|
FrameElement3
|
|
FrameElement4
|
|
Segment1
|
|
FrameOpening1
|
|
VentPart1
|
|
VentElement1
|
VentElement2
|
VentElement3
|
VentElement4
|
VentOpening1
|
FrameOpening2
|
|
VentPart2
|
|
VentElement1
|
VentElement2
|
VentElement3
|
VentElement4
|
VentOpening1
|
The projectpool
Open projects in JoPPS are maintained in the projectpool: the projectpool is a list of all open projects. Only one project in the projectpool can be the active project. The active project is the project the user is currently working on - the active project is called the current project.
The projectpool can be used to perform file operations on open projects such as
open a new project,
save a project,
close a project,
create a new project,
make a project the current project,
etc.
Since JoPPS v2 we can access the projectpool using the POOL object variable. Refer to Projectpool objects - working with project objects for more information on accessing the projectpool using objects.
You can still manage the projectpool from your scripts using the older v1 functions : (JoPPS v1.x)
GetActiveProjectIndex
|
Returns the projectpool index of the active project
|
ProjectCount
|
Returns the number of open projects (eg. the size of the projectpool)
|
ProjectClose
|
Closes the current project
|
ProjectNew
|
Creates a new project
|
ProjectOpen
|
Opens a project
|
ProjectSave
|
Save the current project
|
ProjectSaveAs
|
Save the current project under a new name
|
SetActiveProjectIndex
|
Makes a project active (eg. sets the current project)
|
Generating results in JoPPS
Generating results in JoPPS consists of two phases :
-
The calculation phase: Calculations are made according to the current calculation mode (See the discussion of the calculation mode below.) The result database is updated. Start calculations by calling the function Calculate. If calculations are successful and the result database is up-to-date the report generation phase will start automatically.
-
The report generation phase : (e.g. the JoPPS report generator) Updates the requested (tagged) reports. Can only be invoked when the result database is up-to-date (e.g. the calculation phase completed without errors). If the result database is up-to-date the report generation phase can be started calling UpdateReports. Results are written to disk when the "SaveToDisk" flag is TRUE.
Related functions:
ActionsEnabled
|
Returns the state of the "ActionsEnabled" flag
|
Calculate
|
Updates the result database.
|
GetCalcMode
|
Returns the current calculation mode.
|
GetSaveToDisk
|
Returns the state of the "SaveToDisk" flag.
|
GetUI
|
Returns the state of the internal UI flag. (show user-interface)
|
ResultsValid
|
Returns TRUE if the result database is up-to-date.
|
SetEnableActions
|
Sets the state of the "ActionsEnabled" flag.
|
SetBatchParams
|
Sets the parameters for calculating in batch mode.
|
SetCalcMode
|
Sets the calculation mode.
|
SetPTableParams
|
Sets the parameters for calculating pricetables.
|
SetUI
|
Sets the state of the internal UI flag.
|
SetSaveToDisk
|
Sets the state of the "SaveToDisk" flag.
|
TagReport
|
Tags or untags report slots to be updated.
|
UpdateReports
|
Runs the report phase.
|
Report slots
Each result report occupies what is called a "slot" in JoPPS. Each report slot is represented by an unique number. The SLOT_xxxxxxxx constants can be used to refer to specific slots. For example the constant SLOT_OFFER represents the standard offer report. Using the TagReport function we can specify which slots should be updated by the report phase (e.g. TagReport(SLOT_OFFER,TRUE)).
Calculation mode
The calculation mode determines how the calculation phase updates the result database. Set the appropriate calculation mode using the function SetCalcMode.
Possible modes are :
Calculate the current assembly only.
|
CALCMODE_GROUP
|
Calculate the active project only.
|
CALCMODE_PROJECT
|
Calculate all projects in the projectpool. The "batch dialog" is displayed when the internal UI flag is TRUE. (see SetUI)
|
CALCMODE_BATCH
|
Calculate pricetables for each assembly of the active project.
|
CALCMODE_PTABLE
|
The report generation phase cannot be invoked when the calculation mode is CALCMODE_PTABLE. Pricetable information can only be requested if the option is included in your license.
Internal flags affecting calculations are:
"ActionsEnabled" flag
An internal flag used to enable or disable the execution of actions related to interfacing machining centers. (MC) This flag is of use only for licenses having the MC option. It can be used to control the generation of machine center instructions. If there is no need to interface with a machine center this flag can be turned off (disabled) to speed up calculations. Normally this is done manually through the JoPPS user-interface.
To set the flag use the function SetEnableActions.
"SaveToDisk" flag
"SaveToDisk" is a JoPPS flag indicating whether or not results generated in the report phase should be written to disk. The state of the "SaveToDisk" flag can be changed using the function SetSaveToDisk.
"UI" flag
If TRUE the internal "UI" flag tells JoPPS to display the :
Batch dialog when starting calculations and the current calculation mode is CALCMODE_BATCH.
Pricetable dialog when starting calculations and the current calculation mode is CALCMODE_PTABLE.
Newproject dialog when calling ProjectNew to create a new project.
If FALSE none of the above dialogs is displayed.