[FREE / Open Source] Dynamic Variables - Create Dynamic Variables

Dynamic Variables

Simple extension for adding dynamic variables! You can rename, get values, delete and more!
P.S. I am just having fun making this extension. You can totally achieve these by dictionary lol

Blocks

Blocks Description
Raises when any error occured.

Params Type
error String
Initialize a variable.

Params Type
name Any
value Any
Initialize list of variables. Both list mustn't be empty. "names" and "values" must a list, and their length must be the same.

Params Type
names List
values List
Returns: Any
Get the value of a variable. If the variable doesn't exist, return null.

Params Type
name Any
Returns: List
Get a list of values. The input should be a list of variable's names. If any of the variables doesn't exist, that item will be null. If the input list is empty, or any errors occurred, return an empty list.

Params Type
names List
Returns: List
Get variables' names by its value. Return an empty list if there are no variables, or when error occured.

Params Type
value Any
Returns: List
Get all of the variable names. Return an empty list if there are no variables, or when error occured.
Returns: List
Get all of the values. Return an empty list if there are no variables, or when error occurred.
Rename a variable. If the old variable doesn't exist, error will occur.

Params Type
oldName Any
newName Any
Rename a list of varibles. All list must not be empty. Length of both list must be the same. If any one of the old names doesn't exist, error will occur.

Params Type
oldNames List
newNames List
Returns: Any
Remove a variable and return removed value. If the variable doesn't exist, return null.

Params Type
name Any
Returns: List
Remove list of variables and return a list of removed values. If any of variable's name doesn't exist, that item of the list will be null.

Params Type
names List
Remove all variables.
Returns: Boolean
Check if given variable name exists. Return true if variable exists, otherwise false. Return false if an error occurred.

Params Type
name Any
Returns: Boolean
Check if given value exists. Return true if value exists, otherwise false. Return false if an error occurred.

Params Type
value Any
Returns: Number (int)
Return the number of variables. Return -1 if an error occurred.
Returns: Boolean
Check if any variables exist. Return true if no variable exists, otherwise false. Return false if an error occurred.

Change Log

Version 2 (1.1)

  • Removed method code and error code; they are useless
  • Changed NumOfVariables to Size
  • Changed IsVariableExist to NameExist
  • Added ValueExist
  • Added GetNameByValue
  • Some methods return "null" instead of "not found"

Download

For more details see here Kodular Community

10 Likes

Wow Nice Extension

Nice extension

Great Extension @WatermelonIce

Using tinydb and clearall when screen initialize?

EDIT:
You must refresh MIT webpage and then it will load proper. This is the case for removing any extension off MIT App inventor 2

Issue you cannot remove this extension once you have added it. App will not load. Errors as shown