Flowchart converts to Basic?

Gramps

Senior Member
This little code example was the result of using the Picaxe Editor's flowchart to Basic converter.
The "Cells" appear to be a unit containing the "if" statement.
My question is, what would this look like if it was simply coded in Basic?
Thanks ,Gramps
main:
Cell_7_3:
high B.7
if pinC.0=1 then
goto Cell_7_5
end if
goto Cell_7_3
Cell_7_5:
pause 500
low B.7
Cell_7_7:
high B.6
if pinC.0=1 then
goto Cell_7_9
end if
goto Cell_7_7
Cell_7_9:
pause 500
low B.6
goto Cell_7_3:
 

premelec

Senior Member
The colon indicates a label that can be referred to with a GOTO - cell: is therefore an entry point. It's a bit sloppy using GOTOs but functional. Could instead be written with subroutines [GOSUB] or a variety of other ways - no right way - some ways clearer than others especially to those who write them ;-0 Try rewriting it yourself...
 

hippy

Technical Support
Staff member
what would this look like if it was simply coded in Basic?
My best analysis is -
Code:
Do
  High  B.7
  Do : Loop Until pinC.0 = 1
  Pause 500
  Low   B.7
  High  B.6
  Do : Loop Until pinC.0 = 1
  Pause 500
  Low   B.6
Loop
It would probably be easier to convert from a screenshot or the posted flowchart file.
 

Gramps

Senior Member
Wow! Half the code lines! Thank you Hippy!
" Try rewriting it yourself..."
I really wish I could! This learning curve has become an overhanging cliff!
Here is the screen shot: 1542287980172.png
1542287980172.png
 

hippy

Technical Support
Staff member
Wow! Half the code lines! Thank you Hippy!
And potentially even less if you use #MACRO ...
Code:
#Macro Sequence(LedPin)
  High LedPin
  Do : Loop Until pinC.0 =1
  Pause 500
  Low LedPin
#EndMacro

Do
  Sequence(B.0)
  Sequence(B.1)
  Sequence(B.2)
Loop
And to minimise memory use -
Code:
#Macro Sequence(LedPin)
  b0 = LedPin
  Gosub Do_Sequence
#EndMacro

Do
  Sequence(B.0)
  Sequence(B.1)
  Sequence(B.2)
Loop

Do_Sequence:
  High b0
  Do : Loop Until pinC.0 =1
  Pause 500
  Low b0
  Return
 
Top