Skip to main content

Miscellaneous

There are some builtin functions that do not fit neatly in the other categories, such as one to jump to another line and some that log useful things for debugging.

The @goto function

@goto allows you to jump generally from a simkey function to where there is a flag placed. These flags are basically named locations in the MACRO section of the code that you can have the compiler jump to whenever needed.

After the rest of the code beyond the flag is finished in the MACRO section, it returns back to where it was in the function.

Note that @goto does not use brackets for the argument, it is just the flag written out, and flags are two dollar signs and any name afterwards.

Here's an example:

<FUNCS>
@use_goto {
@goto $$MY_FLAG # Jump to that flag #
a
}

<MACRO>
@use_goto
a
b
$$MY_FLAG # Flag to jump to #
c

# c, a, a, b, c will be the output #

Ways to stop the script (@exit, @end)

There are a couple ways to stop the script, either by raising an error using @exit, or by using @end which behaves differently depending on where you do it.

The @exit function takes a message and throws the error. The message is in the form of a "LOOSE", which is essentially a string without quotations around it. This is useful (and ideally should only be used) when validating some vector input you received.

The @end "function" stops the script at that point without any message if it is put plainly in the MACRO section or within a function. However, within loops it will generally just break out of the loop.

Here's an example of using the two of them:

<VECTORS>
# Takes input (will show in the app when configuring) #
$delay = 0 | input

<MACRO>
# Example of @end within a loop #
@repeat [2] {
@end # Will just break out on the first run #
}

# Check if the delay is valid then use it, otherwise use @exit #
@if @e[$delay < 0] {
@exit [Delay cannot be a negative value.]
}
<$delay>

@end # Will end the script, none of what is after will be included #
abc

Other useful ones

The most important remaining one is @scroll, which allows you to scroll an integer amount of notches.

Aside from that, there's a builtin called @with which takes any amount of keys, and holds them while doing everything in its given block.

Here's an example for both of these functions:

@scroll [5] # Scrolls down 5 notches #
@scroll [-5] # Scrolls up 5 notches, gets to initial place #

@with [CTRL, SHIFT] {
# Everything here is done with CTRL and SHIFT being held #
a
b
c
}

Writing a script for typing out a sentence can be annoying, so you can use @type instead. It takes a NUM, STR, or LOOSE, and types out what it is given.

note

Strings dont actually exist in Simkey as it is just a way of passing arguments, so what you type out might be interpreted literally between the quotations. Remember to escape closing brackets of the kinds } and ].