if MaxLevel >= 5 then
Divisor = Divisor + 1
ChangeTimer = 0
end if
else
if MaxLevel < 4 then
if Divisor > 65 then
ChangeTimer = ChangeTimer + 1
if ChangeTimer > 20 then
Divisor = Devisor -1
ChangeTimer = 0
end if.....
The rest of it I can't figure out as there are multiple ifs and else if which I don't think GCB has. Can anyone with a bit of Arduino background give me a hand? I am at a loss... Thanks for any and all help!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You are close. Not a constraint of Great Cow BASIC to complete.
~~~~~
if MaxLevel >= 5 then
Divisor = Divisor + 1
ChangeTimer = 0
end if
else
if MaxLevel < 4 then
if Divisor > 65 then
ChangeTimer = ChangeTimer + 1
if ChangeTimer > 20 then
Divisor = Devisor -1
ChangeTimer = 0
else
ChangeTimer = 0
end if
end if
end if
~~~~~
Code not tested\compiled. Buyer beware. 😃
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The braces are unballanced in the origional Arduino code so it is not a functional example to start with.
However it looks like the missing brace should be between lines 9 and 10.
With that corrected this is how I would write it in GCBasic:
sub Arduino
if (MaxLevel >= 5) then
Divisor += 1
ChangeTimer=0
else
if(MaxLevel < 4) then
if(Divisor > 65) then
if(ChangeTimer++ > 20) then
Divisor -= 1
ChangeTimer=0
end if
end if
else
ChangeTimer=0
end if
End if
end sub
insufficiant info was supplied for testing but this code should work.
Simplifying the if statement and eliminating redundancys we get:
sub Arduino
if (MaxLevel >= 5) then
Divisor += 1
else
if((MaxLevel < 4) and (Divisor > 65)) and (ChangeTimer++ > 20) then Divisor -= 1
End if
ChangeTimer = 0
end sub
Cheers
Chris
Last edit: Chris Roper 2016-07-12
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Looks like K&R C code to me. Is this all the code? Also, the first endif needs to be removed.
if MaxLevel >= 5 then
Divisor = Divisor + 1
ChangeTimer = 0
else
if MaxLevel < 4 then
if Divisor > 65 then
ChangeTimer = ChangeTimer + 1
if ChangeTimer > 20 then
Divisor = Devisor -1
ChangeTimer = 0
end if....
OR more like this.
if MaxLevel >= 5 then
Divisor = Divisor + 1
ChangeTimer = 0
else
if MaxLevel < 4 then
if Divisor > 65 then
ChangeTimer = ChangeTimer + 1
if ChangeTimer > 20 then
Divisor = Devisor -1
ChangeTimer = 0
else
ChangeTimer = 0
end if
end if
end if
end if
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Also, is there any limit, other than memory for else ifs, ie...
if (MaxLevel >= 5) then
Divisor += 1
else
if((MaxLevel < 4) and (Divisor > 65)) and (ChangeTimer++ > 20) then Divisor -= 1
else
if bla bla bla then
bla bla bla
else
if bla bla bla bla then
bla bla bla
else
if bla bla bla bla bla then
bla bla bla
End if
Last edit: viscomjim 2016-07-12
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
No. The syntax is if - then - else - end if. Yoy cannot use if - then - else - else - else - bla bla- end if. This is a constraint of Great Cow BASIC and also see this Google search - this will highlight some of the views of using if statements.
There are better options to resolve this Select Case - Case - End Case
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am trying to convert some Arduino code to GCB as follows...
Here is what I am guessing at...
The rest of it I can't figure out as there are multiple ifs and else if which I don't think GCB has. Can anyone with a bit of Arduino background give me a hand? I am at a loss... Thanks for any and all help!
You are close. Not a constraint of Great Cow BASIC to complete.
~~~~~
if MaxLevel >= 5 then
Divisor = Divisor + 1
ChangeTimer = 0
end if
else
~~~~~
Code not tested\compiled. Buyer beware. 😃
The braces are unballanced in the origional Arduino code so it is not a functional example to start with.
However it looks like the missing brace should be between lines 9 and 10.
With that corrected this is how I would write it in GCBasic:
insufficiant info was supplied for testing but this code should work.
Simplifying the if statement and eliminating redundancys we get:
Cheers
Chris
Last edit: Chris Roper 2016-07-12
Looks like K&R C code to me. Is this all the code? Also, the first endif needs to be removed.
Thanks all for the help. A couple of things...
I didn't know you could do something like this
ChangeTimer++ > 20
very cool!
Also, is there any limit, other than memory for else ifs, ie...
if (MaxLevel >= 5) then
Divisor += 1
else
if((MaxLevel < 4) and (Divisor > 65)) and (ChangeTimer++ > 20) then Divisor -= 1
else
if bla bla bla then
bla bla bla
else
if bla bla bla bla then
bla bla bla
else
if bla bla bla bla bla then
bla bla bla
End if
Last edit: viscomjim 2016-07-12
No. The syntax is if - then - else - end if. Yoy cannot use if - then - else - else - else - bla bla- end if. This is a constraint of Great Cow BASIC and also see this Google search - this will highlight some of the views of using if statements.
There are better options to resolve this Select Case - Case - End Case
Thanks for that info Evan. In using Select Case, can you pass variables to different subroutines something like this...
Or can you call the same sub and pass different variables like this...