How to check if variable exist in OB2 using lolicode?

It is something like this ?

IF STRINGKEY @variable DoesNotExist
DO THIS
ELSE
DO THAT
END

EDIT: This gives an error.

IndexOutOfRangeException

Index was outside the bounds of the array.

The error only occurs when trying this code

You cannot check if a variable exists since it’s compiled code, not interpreted like in OB1. The Exists / DoesNotExist keywords in a key only check if the variable contains a null value.

Alright, so is there a workaround for this ?

Not really, can you explain to me a use case where it could be useful? With some code maybe?

I sorta got it to work.
At the beginning of the LoliCode add:
SET VAR Expires "empty"

Then in a later state, check and see if the default value empty has been changed.
If yes, do this, else do that.

Hope that makes sense.

IF STRINGKEY @Expires Contains "empty"
data.STATUS = "CUSTOM";
END

Is there a way you can set a CUSTOM status ?

In example, account expired, no subscription etc…

1 Like

Edit the Environment.ini file and add other custom status entries like

[CUSTOM STATUS]
Name=MYCUSTOM
Color=#FFA5FF

Then restart OB2. Mind that if you give the config to other people they will have to make this edit as well in their environment file.

1 Like

Thanks bro for all your hard work!
/closed