> For the complete documentation index, see [llms.txt](https://aixbytes.cedric.kim/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://aixbytes.cedric.kim/snippets/defining-functions-variables-and-events.md).

# Defining functions, variables, and events

Defining public functions, variables, and events that can be used from App Inventor.

{% tabs %}
{% tab title="Function that returns nothing" %}

```java
@SimpleFunction(description = "Does a thing")
public void FunctionWithoutReturn() {
    // Code to execute here
}
```

{% endtab %}

{% tab title="Function that returns a value" %}

```java
@SimpleFunction(description = "Does a thing and returns a result")
public Object FunctionWithReturn() {
    // Code to execute here
    return whateverYouWantToHaveAsAReturnValue;
}
```

{% endtab %}

{% tab title="Normal variable" %}

```java
private Object someVariableValue;
@DesignerProperty
@SimpleProperty(description="Gets the value")
public Object someVariable(){
    return someVariableValue;
}
@DesignerProperty
@SimpleProperty(description="Sets the value")
public void someVariable(Object newValue){
    someVariableValue = newValue;
}
```

{% endtab %}

{% tab title="Variable only settable from designer" %}

```java
private Object someVariableValue;
@DesignerProperty
@SimpleProperty(description="Gets the value")
public Object someVariable(){
    return someVariableValue;
}
@DesignerProperty()
public void someVariable(Object newValue){
    someVariableValue = newValue;
}
```

{% endtab %}

{% tab title="Variable only accessible from code" %}

```java
private Object someVariableValue;
@SimpleProperty(description="Gets the value")
public Object someVariable(){
    return someVariableValue;
}
@SimpleProperty(description="Sets the value")
public void someVariable(Object newValue){
    someVariableValue = newValue;
}
```

{% endtab %}
{% endtabs %}
