Creating a New Macro

From Flowcode Help
Jump to navigationJump to search
See Macro Icon Properties

Select the 'New' option from the 'Macro' menu or press Ctrl+M to create a new macro. You can also create a new macro using the 'Macros' section of the Project Explorer by clicking the arrow next to the 'Macro' item to open up a menu, then selecting 'Add new' from the menu.

Your created macros will be displayed in a list in 'Macros' section of the Project Explorer, here you can add new local variables and constants as well as parameters if you did not do so earlier, you can also delete or edit existing local variables, constants and parameters.


The Macro dialog will appear with the various options and information available to include:

Gen Creating a New Macro 01.png



Standard Features

Name

Enter a name for the macro. If the name that you enter for the new macro already exists, then Flowcode will prompt you for a different name.


Description

Enter a description of the macro and its functions. The description text will appear at the top of your macro flowchart above the Start icon.


Parameters

Adds a list of parameters that are required to be supplied to the macro. A parameter is an input to a macro and used to pass information to set the macro to do something specific. These variables are local to the macro and so will be affixed with a . before the variable name. When you call a macro each parameter will need to have a valid macro. Refer to component macros for examples of parameters in action.

Set the Name and type of the parameters.

Parameters can be added, edited or deleted.


Variables

Adds a list of variables that are required to be used by the macro. These variables are local to the macro and so will be affixed with a . before the variable name. These variables will only exist while you are inside the macro and so allows the overall RAM usage of your program to be lowered.


Constants

Add, edit and delete constants which are only available to the selected macro.


Return type

Specify the return type, or "No return variable" if the macro does not return a value. The return variable is referenced in your macro by referring to the .Return local variable.


Private Flag

When creating a new macro for a component using the customized code feature you will be given a tick box allowing the macro to be private. If the macro is set to be private then the macro will not appear in the main Flowcode component macro list. This is useful for creating invisible helper functions such as the LCD RawSend function.


Video instructions

See the Adding Macros video for information on creating a macro, the video shows the creation of a macro in a practical manner which covers the available functionality such as adding a parameter to the macro as well as creating a variable whilst also differentiating from global and local variables and constants.

{{#ev:youtube|5Z3zbVR7ZZY|640}}


Advanced Features

Adding parameters via the macro name

By typing the parameter types and parameter names you require for the macro in the macro name you can automatically generate any required parameters.


By typing the value in like this.

Macro AdName.jpg


Pressing enter will allow the parameters to be automatically generated.

Macro AdName2.jpg

Adding multiple parameters of the same type

When adding parameters of certain types you can specify multiple variables at once by adding the names of the parameters with comma separated syntax.

Macro AdVar.jpg


Pressing OK will allow the parameters to be automatically generated.

Macro AdVar2.jpg


This syntax also works when creating local and global variables.