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.
Simple switch statement
-
- Posts: 15
- http://meble-kuchenne.info.pl
- Joined: Fri Dec 06, 2024 4:41 pm
- Has thanked: 1 time
-
- Valued Contributor
- Posts: 1677
- Joined: Thu Dec 03, 2020 10:57 am
- Has thanked: 373 times
- Been thanked: 581 times
Re: Simple switch statement
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
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
-
- Posts: 1
- Joined: Fri Aug 22, 2025 7:43 am
Re: Simple switch statement
Thanks you so muchchipfryer27 wrote: ↑Thu Aug 21, 2025 3:46 amHi
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