Startup function in Bitlash won´t execute if created during compile time.


I´m not sure if this is the right place for Bitlash questions but here goes.

I want to create a Bitlash function that is called when Bitlash is booted up. This can be done during runtime using: function startup {print "Some nice text\n",;};

My question is how to add this function or behavior in my sketch? I have tried to create a user function like below but it doesn't seem to be called during boot.

numvar startup(void) { 
        Serial.write ("Some nice text\n");
addBitlashFunction("startup", (bitlash_function) startup);

the function call needs to be inside a function, not at global scope.

To call a function before setup() runs, use a global variable.

struct SetupBitlash{
  SetupBitlash(){ addBitlashFunction("startup", (bitlash_function) startup); }

SetupBitlash sbl;

Thanks for the prompt answer! :open_mouth:

I didn't get what you suggested to work. It compiles fine but the startup function is still not being called during boot. I managed to get it to work in another way though.

I added a user built-ins function in ..src\bitlash-builtins.c

BUILT_IN("startup",     "print \"Some nice text\"")

I have no idea if this is the correct way of doing it though...