Page 1 of 1

Connection points

Posted: Mon Dec 06, 2021 10:50 pm
by WingNut
I've been trying to jump from a macro back to the start of the main macro, after an initialisation of lcd and sd card and rtc. I.e. a reset without the first stages. It wont compile and says its an invalid connection point. Can I only jump within the macro that the connection is within?
N

Re: Connection points

Posted: Mon Dec 06, 2021 11:23 pm
by medelec35
Yes you can only jump within a user macro.
Jumping is not recommended within programming as it causes all sorts of issues.
What I do is use continual loops, e.g Loop until .Exit = 1
Try to avoid call a user macro from another user macro.
You will be better of using a state machine type of program.

Re: Connection points

Posted: Tue Dec 07, 2021 6:41 am
by WingNut
Ok thanks. I'll read up on state machines

Re: Connection points

Posted: Tue Dec 07, 2021 8:19 am
by mnfisher
If doesn't sound as though you want to jump back to the start of the main macro...

Main macro will call initialization code - if you jump back to the start then it will call the initialization again - actually just returning from the macro will do what you want - which is continue program execution after the setup code...

Code: Select all

Main
  Call setup macro
  More setup macro
  Do stuff
I
Returning (in effect dropping of the end of a macro) returns to where it was called from. Except main - which has Asian infinite loop at the end....

Martin

Re: Connection points

Posted: Tue Dec 07, 2021 8:41 am
by WingNut
At the moment (and I'm still developing this in my head) I want to go back to a state after initialisation. Like a reset but not total reset. I want to use as few buttons as possible to display and control a menu and modify some config settings on an sd card. So in my head max of 3 buttons and the flow through the menu system will change the purpose of the buttons depending which stage of the menu the user is at. This is probably the most complex part of the project so far and its been a steep and huge but satisfying learning curve.

My initial thought was a jump straight out to the start of the main code after initialisation if the user had made a mistake or changed their mind

N