When composing complex and dynamic HMIs, Magneto Studio® allows for non-predefined directives to be integrated in the form of code expressed in C language syntax but used with the same ease as a script. This choice allows for optimal embedded development while remaining within the reach of a non-developer (the general expressions remain as simple as Javascript or Python).

Information (developer): single quotes (') are used to indicate that this is code that will be compiled directly. The included expression can be either a single statement, a sequence of statements or a call to a function declared and instantiated in the user source code. In any case, it must respect the syntax of the C language.
Tip: If the result obtained does not correspond to that expected during development, opening the terminal (area 5) will provide information about errors specific to the program generation stages (compilation and linking phase).


Assigning variables to text

Once you have created your variables, we will see how to assign them to elements of your interface.

To do this :

  1. Create or select a text.
  2. Make the text editable by clicking on the "Editable" checkbox in the properties area (area 3).
  3. Open the editor (format for saving a project), click on the "Editor" button (area 4).
  4. Search in the editor for your text object.
  5. Edit " text : " by returning your variable in the single quotes. (exemple : " text : ‘return Heures;’ ").

Assigning a function to an action

To assign a function to an action you must either have imported your code into the project (in C Language) and have previously activated the necessary libraries if needed (see the section Importing your source code) or use standard C code.

Once done:

  1. Create an action.
  2. Choose the "code" type.
  3. Open the editor.
  4. Edit line "onPress : " and replace by "onPress : 'maFonction();' "

Example of a standard code call:

  • Edit the line " onPress : '' " and replace by " onPress : 'printf("Hello World !");' "