Omission of SELECT CASE in Flowchart and Blockly

GrahamGo

Senior Member
I am just curious. I started out using Flowchart and found out that CASE is not supported. I found it easy to add it in using the BASIC code block. Then today I started to look into using Blockly and found out that SELECT CASE isn't available there either.

So my question. Why is SELECT CASE omitted, is it slow or something? What is the best way to implement/replace it (stacked IF .. THEN's ?)

I also dont understand why other simple commands are missing. like PULLUP mask and INPUTTYPE mask. Both useful and might be implemented as an option within the START block?

First impression is that Blockly runs faster than the Flowchart method. But I suspect normal code entry might be the optimum method. Its an interesting learning curve. I also find that PICAXE editor suite tends to be a little sluggish. So I might need a quicker PC!
 
Last edited:

hippy

Technical Support
Staff member
The most Blocky-like way of creating a SELECT-CASE is with an IF block and using the modifier to add additional ELSE IF clauses ...

SelCase.jpg
 

GrahamGo

Senior Member
Thank you very much. You helped me discover the gear wheel Modifier. The multiple VARA tests seem unnecessary, But it works. Here is my final working example.

Does Blocky replace or enhance Flowchart? I dont understand whether one is preferred over the other and why?
 

Attachments

hippy

Technical Support
Staff member
Does Blocky replace or enhance Flowchart? I dont understand whether one is preferred over the other and why?
Blockly and Flowcharting are just two additional ways to represent program code as an alternative to Basic language text. Which is preferred mostly comes down to personal choice though one can argue advantages and disadvantages of each.

The biggest advantage of Blockly is that it is all block structured; there is no way to jump all over the place ( except for procedure calls which come back to where they started from ), and it's pretty clear where things should be dropped in to complete the program.

Blockly also seems to be something which is easy to use and fairly intuitive. All that put together means that it should be easier to produce programs which work.
 

GrahamGo

Senior Member
Yes, in the short time that I have been using Blockly I can see that it is useful. I seem to lean towards Blockly, it just seems to run quicker. If I persist at this I can imagine using Blockly to block out the program, then switch to Basic in order to optimize (like replacing the If-then's with a Select Case in this example. I have just found that I can name variables, so things are looking up! But I appreciate the your help, thank you!
 

hippy

Technical Support
Staff member
I seem to lean towards Blockly, it just seems to run quicker.
To an extent it probably is. Flowchart and Blockly both convert to Basic source code behind the scenes, which is compiled to executable code and then downloaded into the PICAXE. Because Flowcharts can jump all over the place there can be more explicit GOTO commands required which need executing. Blockly, being implicitly block-structured, will not need such GOTO commands and allows more optimal Basic source code to be generated.

If you click on the "Convert" ribbon option or toolbar icon when a Flowchart or Blockly program is shown in PE6 you can see what Basic source code is generated.
 
Top