Wheel IDE

Online demo »

Meta commands

Meta commands are parsed by the preprocessor.

#include

With the #include command you can import an existing file like a library.

#include "lib/modules/screen.whl"

proc main()
    drawNumber(10, 5, 90)
end

#define

With the #define command you can create constants, the constants are replaced with the defined value by the preprocessor.

#include "lib/modules/screen.whl"

#define MY_NUMBER 55

proc main()
    ; Draw the number 55:
    drawNumber(10, 5, MY_NUMBER)
end

#ifdef, #else, #end

The #ifdef meta command allows you to conditionally compile a block of code. The #ifdef command checks if a value is defined, if the value is defined then the code between the #ifdef and the #end line is compiled. This command only checks if a value is defined, the actual value is irrelevant.

The following example shows how to log a number if a value is defined:

#include "lib/modules/screen.whl"

#define LOG_NUMBER "The number should be added to the console log..."

proc main()
    number n
#ifdef LOG_NUMBER
    printN(n)
#end
end

With the #else command you can compile code if the #ifdef condition fails:

#include "lib/modules/screen.whl"

proc main()
    number n
#ifdef LOG_NUMBER
    printN(n)
#else
    clearConsole()
#end
end

Global defines

It's also posible to define constants in the IDE from the Defines option in the Compiler menu. Values configured here can be used in different programs and are stored in the settings.

#project

With the #project command you can set the name of the program. The name should be given as string value.

#define "This is my project"

proc main()
end

#optimizer

The #optimizer command turns the optimizer on or off, valid values are "on" or "off" strings. The optimizer is turned on by default.

#optimizer "off" ; Turn the optimizer off...

proc main()
end

#datatype

The #datatype meta command tells the VM what kind of heap memory to allocate. There are three possible values:

#datatype "int"

proc main()
end

#heap

With the #heap command the amount of allocated memory for the virtual machine can be set. The default setting is 1024 memory entries (floats). The heap value should be given as a positive number. In the following example the amount of heap is increased to 4096 memory entries, this equals 16 kBytes.

#heap 4096 ; Set the heap size to 4096 floats...

proc main()
end

#stringcount

The #stringcount command sets the maximum number of strings which can be allocated. The default setting is 64.

#stringcount 64 ; Set the number of strings to 64...

proc main()
end

#stringlength

The #stringlength command sets the maximum string length which can be allocated. This value should be larger than 0 and less than 128. The default setting is 64.

#stringlength 64 ; Set the maximum string lenght to 64...

proc main()
end

#rangecheck

The #rangecheck command turns the runtime range checking on or off, valid values are "on" or "off" strings. The range checking is turned on by default. Turning range checking off improves the performance of you application, this can be helpfull when deploying your application on the EV3.

#rangecheck "off" ; Turn range checking off...

proc main()
end

#image

The #image command can be used to create images, with the #image command the filename can be declared. The filename should have an .rgf extension. The #image command should be followed by one or more #data commands, these contain the image data. Each #data command expects a string parameter with the same length as the first data command. The data string may only contain "0" or "1" characters.

#image "myImage.rgf"
#data "0100010"
#data "1001001"
#data "0100010"

proc main()
end

#text

The #text command can be used to create text files, with the #text command the filename can be declared. The filename should have an .rtf extension. The #text command should be followed by one or more #line commands, these contain the text lines. Each #line command expects a string parameter.

#text "myText.rtf"
#line "The quick brown fox..."
#line "jumped over the lazy dogs back."

proc main()
end

#break

The #break command sets a breakpoint on a line, difference between this command and a breakpoint in the gutter is that the breakpoint set with the #break command is saved in the file.

number n

proc main()
    n = 11
    ; Set a breakpoint...
#break
end

#resource

With the #resource command you can declare a resource which will be downloaded to the EV3 when you install your compiled program. There are four valid resource file extensions: .rtf, .rgf, .rsf, .rbf, .wfrm.
The resource file should exist within the Wheel path.

#resource "resources/images/expressions/Smile.rgf"

proc main()
end

#display

The #display command allows you to show the sensors and/or motors in the simulator, it expects one parameter: a comma separated list of plugin names to be shown.
The command is executed when the source file is loaded in the IDE and when the program is compiled, when the following file is loaded then the simulator EV3 and EV3 Sensors plugins will be shown:

#display "EV3,EV3 Sensors"

proc main()
end

To display the console the "Console" parameter can be used:

#display "Console"

proc main()
end

#noformat

The #noformatter prevents code after that meta command from being formatted.

#format

This command enables code formatting again and should only be used after the #noformat meta command.

#alias

Set a device alias. This command expects two string parameters, a uuid string and the alias for the uuid.

#alias "5107039b87e0459898e438d27b9e2c40" "My Powered Up device"

proc main()
end
See also: syntax(Syntax)