The Crew Pricing Script Editor is a powerful utility that will allow you to write your own code for calculating the cost of your crew. The Script Editor supports 4 different languages:
PASCAL
J JSCRIPT
C++
Visual Basic (VB)
1. | Two Script Editors. The 'Crew Script' tab is where your actual price scheme is written; however, in order to be able to look at other scripts or try out bits of experimental code, there is a 'Doodle Script' tab that works completely independently. When you save your work its the Crew Script that gets posted to the table that looks after this data (pricedat.db). |
2. | Testing your code. The 'Parameters' box allows you to set trial a trial date range and crew rate (per hour, per day, etc) for your scheme. The outcome after the script is displayed in the 'Total Charge' box. This can only be achieved if four global variables Start, Finish, Rate & Crew Price declared in each script and these are automatically mapped to the data in the four controls in the Parameters box: 'From..', 'Until.', Rate, 'Total Charge'. For this reason, these global variables are required for each script and a warning is displayed if they are not found when the script is run. Obviously, the final price that you are trying to calculate should end up in the Crew Price variable. Of course, when you are on the 'Doodle Script' tab you may want to work independently of these variables that are used for input / output, so you can turn off the test by checking the 'Bypass' check box. |
3. | Sample scripts. Four sample scripts (1 daily, 3 hourly) are supplied with the programme, and there is a set for each language, so when you select a sample script it will match the language you have selected. Sample scripts automatically overwrite what is on the active script tab when selected so you may wish to be on the Doodle Script tab when you select one. |
4. | Loading and Exporting. A script can be loaded from a file, and then saved to the database, which will able you to get scripts from a third party; similarly you can export a script from to file, enabling you to send you work to the support desk for example. |
5. | Script Editor functions. Copying, Pasting, Selecting, etc are supported by the script editors, and these can be invoked from a popup menu, the Edit menu, or keyboard shortcuts (e.g. Ctrl + C). There is also an Undo facility. |
6. | Running the script. When you click the Run(F9) button the editor caret will go to any line that contains a syntax error and the message panel at the bottom of the scripting form will display the nature of the problem. You can step through your code one line at a time using the Step(F8) button; this is particularly useful when you want to Evaluate(F10) the value of a (global) variable in the script. Just copy the name of the variable, paste it into the Evaluation form's edit box and hit Return. In the unlikely event that you have written something so buggy that it crashes the programme when it runs you can turn on the 'Save On Run' option from the Database menu. |
7. | Special Functions. The Crew Script Editor comes with a large number of classified functions to help you write efficient code and these are detailed on the functions page. The functions can be selected from the Tree View on the right of the main form and dragged onto a script editor, and when this is done the function definition is copied so that you are aware of the input parameters and output value types, e.g.
DaysInMonth(const AValue: TDateTime): Word
Obviously, this would be used like this:
MonthDayCount = DaysInMonth(Start); |
There are some limitations to the script editor and these include:
• | No type declarations (records, classes) in the script; no records, no pointers,no sets (but you can use 'IN' operator - "a in ['a'..'c','d']"), no shortstrings, noGOTO statement. |
• | C++Script: no octal constants; no 'break' in the SWITCH operator (SWITCH works like Pascal CASE); '++' and '--' operators are possible only after thevariables, that is '++i' is not allowed; '--', '++' and '=' operators do not return a value, that is 'if(i++)' is not allowed; all the identifiers are case-insensitive; NULL constant is the Pascal Null - use nil instead of NULL. |
• | JScript has no types, all types are variants. |
• | BasicScript may have types (for example, dim i as Integer), or may have no types and even no variable declaration. In this case a variable will have Variant type. |