The Startup Code region allows you to enter Maple code to be executed every time the current document is reopened.
Note that when you restart the Maple server, your start up code will be re-executed.
User Profiles and Startup Code
Startup code can include loaded packages, defined variables and procedures, and any other Maple commands.
Maple code applied by a User Profile appears at the beginning of the startup code. Your startup code must start after the end of the User Profile code (see the following section on User Profiles and Startup Code for details).
The commands entered in the Startup Code region do not appear anywhere in the Maple document, and can only be accessed by opening the Startup Code Editor. This provides you with a cleaner way to generate Maple documents with no visible code.
To enter startup code, go to the Edit menu and select Startup Code. Alternatively, click the Edit startup code icon (
if your worksheet does not have startup code or
if your worksheet has startup code or an applied User Profile with Maple code). A Code Editor appears in which you can enter Maple commands.
When writing a procedure within the startup code region, you can press the Enter key to advance the cursor to the next line. Indenting lines of code in a procedure is done automatically. Indenting is preserved when advancing the cursor to the next line.
The startup code editor offers command completion popups when you type the first few letters of a Maple command name.
For long programs that requiring scrolling the code editor window, a black line in the scroll bar indicates the approximate position of your cursor in the lines of code.
At any time while entering your Maple commands in the editor, you can check for syntax errors. By default, automatic syntax checking is enabled. This provides continuous syntax checking. To turn this feature off, clear the check box Check Syntax Automatically in the Edit menu. As an alternative, perform a syntax check: From the Edit menu, select Check Syntax Now. It is recommended that you check the syntax before saving, so that your startup code doesn't prevent Maple from successfully opening.
If there is a syntax error in your code, it will be underlined in the code editor. Also, a red line will appear in the scroll bar at the location in your code where the syntax error appears.
Set the syntax checking level using Edit > Check Syntax Level or through the Options Dialog. You can also turn automatic syntax checking on or off through the Options dialog.
When you are finished defining your startup code, and you have checked the code for syntax errors, close the editor. To save the code and exit, either select Save Code from the File menu, or click the Save the active file icon. To exit without saving, either select Exit from the File menu, or click the x in the upper right corner of the startup code window.
To check that your startup code works as desired, save the current document, close it, and then reopen it. You can then check that packages were loaded, variables were assigned, and other code was successfully compiled.
The Diagnostics panel at the bottom of the Startup Code Editor window displays the output from code analysis done on any Maple code entered into the code editor.
The Console panel displays output from the code entered in the Startup Code Editor. The Console can be used for prototyping and testing your code. To clear the Console, from the View menu, select Clear Console.
Maple commands from a User Profile's [MapleCode] section appear at the very beginning of the Startup code region. The User Profile commands are executed before the worksheet's startup code.
The User Profile code is inserted between the ## BEGIN USER_PROFILE: and ## END USER_PROFILE: comments. For example, the following figure shows the startup code for a worksheet that had a User Profile called LinearAlgebra applied to it. The User Profile contains two commands: with(LinearAlgebra) and a Matrix variable assignment.
Your startup code must begin after ## END USER_PROFILE:.
It is not recommended that you use the Startup Code Editor to update User Profile commands for the following reasons:
The User Profile section is deleted and replaced when another User Profile is applied to the worksheet. Therefore, your changes will be lost if you apply another User Profile to the worksheet.
The User Profile section must follow a particular format. Altering this format can result in unexpected changes to your startup code when you apply another User Profile.
If you must edit the commands in the User Profile section, do one of the following:
Remove the lines with the ## BEGIN USER_PROFILE: and ## END USER_PROFILE: comments. This converts the User Profile to startup code, which is not changed when you apply a User Profile.
Edit the User Profile and then re-apply it. This guarantees that the changes are applied to current worksheet and to any other worksheet that you apply the User Profile to.
For more information on User Profiles, see User Profile and Create a User Profile.
Create a User Profile
Syntax Templates for Code Editing
Download Help Document