Ryerson Crest Ryerson Header

MTH 207 Lab Lesson 17

Text in Maple


Up to Main Lab Page Next Lesson - - Approximating Functions Previous Lesson - Procedures

With the ability to write procedures comes the task of documenting our code. In addition it is useful to be able to write textual comments about certain lines in our session. In order to be able to do these tasks Maple allows for entering lines of text.

Execution Groups

Maple groups lines together into execution groups. Different groups are indicated by the symbol. When a complete command is entered in Maple a new execution group is created for the next command. Some commands may contain many lines within the same execution group, for example if...fi; do..od; proc...end; all define only one execution group (Maple may generate spurious warnings). In these cases the execution group symbol expands to indicate the group.

Enter a (short) multiline procedural definition and note how the execution group symbol expands to encompass all the lines.

Entering Text

It is possible to have text at any point within any execution group.
Text is ignored by Maple during execution.
A line which cointains only text, and no Maple cursor ( > ) is called a text line
A group that contains only text lines is called a textual group and is ignored by Maple for execution purposes, the cursor skips past the group on execution.
By default text appears in black, rather than red, but this can be changed in the < Format > < Character > menu.
A line which cointains a Maple cursor ( > ) is called an execution line.
Note that an execution line may contain text.

To enter text mode place your cursor at the point where you want to start entering text and do one of the following:

Select < Insert > < Text Input > from the menus,
Press < cntrl > T,
Press the button on the button bar.
Anything you now enter will be considered as text by Maple.

Note If you are on an empty execution line the Maple cursor ( > ) will disapear and you will create a text line.
If all lines within a group are text lines it is a textual group.

Alternatively you can create a new text line within the current group:

< cntrl > < Shift > J, or < Insert > < Paragraph > < After > creates a new text line after the current one.
< cntrl > < Shift > K, or < Insert > < Paragraph > < Before > creates a new text line before the current one.
< cntrl > M, or < Insert > < Maple Input > changes an empty text line back to an execution line.

In text mode the second button bar changes to a text formatting bar, allowing you to choose a font, specify bold, underline or italics, or justify text.

Since you are now entering text Enter produces a new line of text within the same group, rather than executing the group and producing a new execution group.
To get a new execution group after the group you are currently in do one of the following:

Select < Insert > < Execution Group > < After Cursor > from the menus,
Press < cntrl > J,
Press the button on the button bar.
Note This will work no matter what kind of line you are currently in and so is also useful for inserting lines of code.

You can also insert an execution group before the current group by:
Select < Insert > < Execution Group > < Before Cursor > from the menus, or
Press < cntrl > K,

Try to enter a few lines of text
Create a Textual group.
Create a mixed group which conatains Maple commands and text.
Create a line which contains an executable Maple command followed by some text.

Math Input Mode - The Prettyprinter

Maple also gives you acces to the prettyprinter. The prettyprinter is the Maple routine that formats mathematical text into a nice pretty looking format for Maple output. To enter pretty mathematical text do one of the following:

Select < Insert > < Math Input > from the menus,
Press the button on the button bar.
A ? will appear in a box and any text you type will be formatted in math mode.
Anything you enter appears as plain text in the second button bar.
Pressing enter exits math mode.

Try to enter the string f(x) = x^2 + sin(x) + sum(1/n^3,n=0..10), using prettyprint
Notice how Maple formats each stage as you go.

In version 4 of Maple the math input mode is a bit finicky.
Once you have pressed enter and exited math input mode you cannot go back and edit the prettyfied text directly. However you can select the box by clicking on it with the mouse, the plain text appears in the second button bar, you can edit the text in the button bar by clicking on it first.

Note that you can use pretty text on a regular input line (execution line), Maple will behave as usual and process the line as normal. This is a handy way to pretty up your work sheets.

Unfortunately, by default if you enter math input mode on an empty text line Maple assumes you want to enter this as a command and provides output and errors. This is a hassle if you just want to enter pretty text at the beginning of a line. One way to tell if Maple thinks this is an input line is that it will appear in red, if Maple thinks it is just pretty text it will appear in black.

If there is any non blank text on a line before the math input box Maple will not do this. So if you want some math text at the beginning of a text line, one trick is to enter some text, place the box after the text, and then delete the text.

The math input box can be hard to navigate around. Maple doesn't like putting things before or after a math input box. To place text after a math input box place the cursor at the end of the box (as far left as possible) and select text mode. This will work for putting text before a math box as well, put the cursor as far right as possible.

Finally Maple has a nasty habbit of deleting math input boxes a bit too hastily. If you press backspace when you are to the left of a box Maple will delete the whole box. If you want to delete some part of the box you have to do it in the second button bar.

I have been told that the new version of Maple (Version 5) significantly aleviates these problems.

Try to enter the string f(x) = x^2 + sin(x) + sum(1/n^3,n=0..10), using prettyprint, as text at the beginning of the line.
Now place the string "An interesting function" after it.
Try entering some Maple commands using math input mode, doesn't your worksheet look pretty?

The F5 Key

The F5 key provides a useful toggle, depending what mode you are currently in.

See if you can use F5 to get Maple to accept the string:
f what := a funny 1 way ; to mix things up.
as
f := 1;
Note you will have to enter this by hand.

Sections

Lines in Maple may themselves be grouped together into sections. Sections may in turn contain subsections.


Up to Main Lab Page Next Lesson - Approximating Functions Previous Lesson - Procedures Top of this Lesson


Maintained by: P. Danziger, March 1998