Page 1 of 1

Simple switch statement

Posted: Wed Aug 20, 2025 11:45 pm
by Billduck1302
What am I doing wrong? I call a subroutine with a switch statement.
It has a local variable ".Count". The switch statement uses ".Count" to go between branches.
But it is not switching, while the .Count increments.
The program is attached.

Re: Simple switch statement

Posted: Thu Aug 21, 2025 3:46 am
by chipfryer27
Hi

A great feature of Flowcode is Debug which allows you to simulate your project, and in that tab "Step Into" is particularly helpful as it allows you to move through your chart a step at a time, whilst displaying variable values.

Using that, you will see the following.

1) Your chart steps through Main until your Macro SwitchTest is called.
2) It then enters the Macro and progresses to the Switch
3) It correctly branches to "1" based on the value of Count_Byte
4) It correctly displays the value
5) It immediately clears the display'
6) It increments Count_Byte
7) It leaves the branch
8) it then exits the Macro back into Main
9) Program then exits

So to see anything on your display you will need to either insert a delay before clearing your display, or better yet just clear the display before updating.

If you want to see the LCD count up, you will need to either have your macro call in Main within a loop, or loop x-times before exiting within the macro.

Hope this helps.

Regards

Re: Simple switch statement

Posted: Fri Aug 22, 2025 7:45 am
by VickiDTownsend
chipfryer27 wrote:
Thu Aug 21, 2025 3:46 am
Hi

A great feature of Flowcode is Debug which allows you to simulate your project, and in that tab "Step Into" is particularly helpful as it allows you to move through your chart a step at a time, whilst displaying variable values.

Using that, you will see the following.

1) Your chart steps through Main until your Macro SwitchTest is called.
2) It then enters the Macro and progresses to the Switch
3) It correctly branches to "1" based on the value of Count_Byte
4) It correctly displays the value
5) It immediately clears the display'
6) It increments Count_Byte
7) It leaves the branch
8) it then exits the Macro back into Main
9) Program then exits

So to see anything on your display you will need to either insert a delay before clearing your display, or better yet just clear the display before updating.

If you want to see the LCD count up, you will need to either have your macro call in Main within a loop, or loop x-times before exiting within the macro.

Hope this helps.

Regards
Thanks you so much