Skip to main content

Algorithm lines in CalcMe

A brand new way to define variables and create algorithms is available in CalcMe The purpose of this page is to provide an outline of what this new feature has to offer, the problems it intends to solve and the expected user interaction.


Problems intended to be solved

After deeply analyzing the CalcMe user experience, we realized several minor issues could be improved with the algorithm lines development. The main problems this new feature intends to address are:

  • It's not possible to copy and paste multiple lines in CalcMe. From now on, it will be possible to easily reuse parts of an algorithm.

  • It's complicated to remember by heart all the commands. The new autocompletion option will help you find the appropriate function at each moment.

  • CalcMe presents performance issues in sessions with an intermediate-length due to the many instances of MathType editors that need to be used. You won't face this problem anymore by generating the algorithms with the provided plain text.

  • It's not possible to add comments inside multiple line structures. Besides, it's also impossible to switch a line from being commented to being active quickly.

Expected user interaction

A new button in the toolbar allows you to instance a code editor. That button enables the algorithm line feature in the current line, and you can enter your algorithms directly there.



User-created functions and constants (such as the represented by r(), create_random_matrix(m,n) and A) get their styling once the code editor loses focus to avoid the performance impact of updating the grammar every keystroke.

On the other hand, variables defined inside a code editor are available in posterior standard CalcMe lines for operations or value checking. Besides, multiple code editors can be created on a page, and each one can access the variables of the previous ones.



If you're using the feature in a WirisQuizzes version before 4.2.7 (which includes WirisQuizzes 3), sessions with only algorithms won't be detected. This can be solved by adding something in CalcMeSheet, as you can see in the screenshot below.


Algorithms already written in CalcMe sheet

If you had an algorithm already written in the CalcMe sheet, you could automatically convert it to the code editor. There is a new button in the toolbar allowing you to do so.



Thus, you will be able to translate those old algorithms that gave you performance problems to the code line box.

About the syntax

The syntax used in the code editors is the Omega language, the internal language of the Wiris CAS kernel. Even though it's very similar to the syntax used in standard CalcMe lines, several actions help you get the correct syntax.

  • Clicking a button from CalcMe menu while inside a code editor will enter its Omega equivalent expression:


  • Using the function name autocompletion mode through the shortcut Ctrl + Space (Cmd + Shift + Space in macOS):


Comment syntax

As mentioned above, it's possible to use the comment syntax within the code editor. You can use the symbol # to mark a line as a comment and the sequence /# to start a comment block (you can close it using the symbol #/).


Search and Replace commands

As a brand new feature of the CalcMe code editor, it's possible to find and replace text if you're working with a lot of text and need to search and replace a word or a phrase.


You can find below the corresponding shortcuts:



Start searching


Find next


Find previous




Replace all



This feature only works inside the code editor. Thus, it's important to set the cursor inside the corresponding text field.

String substitution command

If you want to use the string_substitution() command within a mathematical expression, you will have to keep using the CalcMe sheet accordingly. It's a limitation of the current editor and, although it's not ideal, the formulas won't be displayed properly if they are included through the code editor.


Algebraic expressions

There are several notation considerations you need to take into account if you want to create an algebraic expression through the code editor. As you can see in the screenshot below, CalcMe will interpret expressions beginning with an alphabetic character as an identifier (in blue), like a reserved word.


This behaviour can involve some validation problems in a WirisQuizzes question context, given that E·13E13.


Thus, to avoid these situations, there are two workarounds you can use indistinctly. We recommend using the first one, as you can keep generating the algorithm within the code editor, but both are equally possible.

  • Insert the dot operation product between all alphabetical characters and numbers.

  • Define such expressions inside CalcMe.