Tips

“msharpmath”, The Simple is the Best

[100] 041 Tips      Tips

//———————————————————————————————————————
//  [edit-window] and [command-window]
//———————————————————————————————————————
An [edit-window] is a text window for editing, and it has a file-name (cemmath1 is by default).

The [command-window] starting with a prompt ‘#>’ works interactively, and its title is by default ‘Command Window for cemmath’.

The [command-window] receives a command and usually prints its result right after the input. For example

  • #> 3 + 4 * 5

ans = 23

In the [command-window], each command is automatically attached by a return key and a semi colon ‘ ;’  for termination of a command (as in C). For example, the above command is actually processed as two-line commands

  • #> 3 + 4 * 5
  • ;

//———————————————————————————————————————
//  print-out control
//———————————————————————————————————————
In the [command-window] starting with ‘#>’, a semi-colon is automatically attached after each return. However, in the [edit-window] with a file name, it is necessary to terminate each command by a semi-colon (as is in C-language).

  • A semi-colon ‘;’ activates print-out.
  • Double semi-colons ‘;;’ suppress print-out.

The above rule is reversed inside a function to save printing load.

EXAMPLE

  • #>  1 ;  2 ;;  3 ;    // 2 ;; is not printed due to double semi-colons
  • ans = 1
  • ans = 3

//———————————————————————————————————————
//  clear command
//———————————————————————————————————————

A ‘clear’ command clears all the variables, functions defined previously. When only a few variables need to be cleared, they are listed after ‘clear’ command.

  • clear ;    // all are cleared
  • clear a, b, c ;   // variables with name ‘a’, ‘b’ and ‘c’ are cleared. Others remain

When used in the [edit-window], the ‘clear’ command must be the last command.

//———————————————————————————————————————
//  comment
//———————————————————————————————————————

A number of methods are provided to handle comments in cemmath :

  • /*  */  block comments as in C
  • //  a single line comment  as in C
  • %>  line comment for print-out
  • %{  %}  block comment for print-out

Two commands ‘/* */’ and ‘//’ do not result in print-out. However, starting with ‘%’ prints comment in the [command-window].

//———————————————————————————————————————
//  print-out commands
//———————————————————————————————————————

When a group of commands in the edit-window are executed, a series of ‘ans’ are displayed in the [command-window]. For example

  • 1+1;
  • 1+2;
  • 1+3;

are executed to result in

  •            ans = 2
  •            ans = 3
  •            ans = 4

In certain cases, users may want to know what kind of commands are responsible for the answers. For this purpose, two printed-out commands are innonated such that

  • #>  line command with print-out
  • #{  #}  block commands with print-out

For example, modifying the aforementioned commands

  • #> 1+1 ;      // comment 1
  • #> 1+2 ;      // comment 2
  • #> 1+3 ;      // comment 3

results in

  • 1 +1;      // comment 1
  •           ans = 2
  • 1+2 ;      // comment 2
  •           ans = 3
  • 1+3 ;      // comment 3
  •           ans = 4

Comments are closed.