-
MathType
-
WirisQuizzes
-
Nubric
-
CalcMe
-
MathPlayer
-
Store FAQ
-
MathFlow
-
BF FAQ
-
Miscellaneous
-
Wiris Integrations
Algorithm lines in CalcMe
Reading time: 3minA brand new way to define variables and create algorithms is available in CalcMe. The purpose of this page is to outline what this new feature offers, the problems it aims to solve, and the expected user interaction.

Problems intended to be solved
After a thorough analysis of the CalcMe user experience, we identified several minor issues that could be improved through algorithm line 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 hard to remember all the commands by heart. The new autocompletion option will help you find the appropriate function at each moment.
- CalcMe experiences performance issues during intermediate-length sessions 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 quickly switch a line from being commented out to active.
Expected user interaction
A new button in the toolbar allows you to instantiate a code editor. That button enables the algorithm line feature for the current line, where you can enter your algorithms directly.

User-created functions and constants (such as those 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 with every keystroke.
On the other hand, variables defined inside a code editor are available in subsequent standard CalcMe lines for operations or value checking. Additionally, multiple code editors can be created on a page, and each can access the variables of the others.

Algorithms already written in the 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 into the code line box.
About the syntax
The syntax used in the code editors is Omega, 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 the 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:
| Action | Shortcut |
|---|---|
| Start searching | Ctrl+F |
| Find next | Ctrl+G |
| Find previous | Ctrl+Shift+G |
| Replace | Ctrl+Shift+F |
| Replace all | Ctrl+Shift+R |
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 that begin with an alphabetic character as identifiers (in blue), such as reserved words.

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

Thus, to avoid these situations, there are two workarounds you can use interchangeably. 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.
