Startup Code - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : worksheet/documenting/startupcode

Startup Code

• 

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.

 

Description

User Profiles and Startup Code

Description

• 

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 Maple Code Edit Region 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.

• 

At any time while entering your Maple commands in the editor, you can check for syntax errors. From the Edit menu, select Check Syntax Now. You can also check the Check Syntax Automatically option to enable continuous syntax checking. It is recommended that you check the syntax before saving, so that your startup code doesn't prevent Maple from successfully opening.

• 

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.

User Profiles and Startup Code

• 

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.

See Also

CodeEditRegion

Create a User Profile

User Profile

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam