question about PBASIC 2.5 comparative operators' syntax (<, >=, etc)
brad_lightwriters
Posts: 3
does anyone know the proper syntax for PBASIC 2.5 for a 'greater than or equal to' statement?· does it matter if there is a space between the > and the =?· does it matter what order the two operators come in?· for example, in my code i have an IF statement with the condition: 'IF variable >= 50'.· i have a feeling that the code is dropping out of this IF statement when the variable gets to 50, not 51 as one would think would happen.· do i need a space between the > and the = or am i totally offbase in my assumption that this is where my error is?·thanks in advance for any help you can offer.·
Comments
if a>=b then........
or, for less than or equal to:
if a<=b then........
All this can be found in the Help file.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Do you have a Stamp Tester yet?
http://hometown.aol.com/newzed/index.html
·
Perhpas you should post your program instead of a fragment -- that will probably shed some light on the problem you're facing.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
CBP_Num_Calculator: 'find the chip, board and pin # from the neon #
··· IF Neon = 100 THEN
······ TempNum = 0
······ ELSE
······ IF Neon >= 75 THEN
······ TempNum = Neon - 75
·········· ELSE
·········· IF Neon >= 50 THEN
·········· TempNum = Neon - 50
·············· ELSE
·············· IF Neon >= 25 THEN
·············· TempNum = Neon - 25
·················· ELSE
·················· TempNum = Neon
·············· ENDIF
··········· ENDIF
······· ENDIF
··· ENDIF·· ' End of this Loop
'
'This following Loop is again conditioning
' the variable TempNum to extract the corresponding Pin#
'
··· IF TempNum = 0 THEN
······ TempNum = TempNum
··· ELSE
····· IF TempNum < = 8 THEN·· 'TempNum minus the number of pins on a chip (8)
········ TempNum = TempNum -1
········ ELSE
········ IF TempNum > 16 THEN
··········· TempNum = TempNum - 17· 'TempNum minus twice the number of pins
··········· ELSE
··········· TempNum = TempNum - 9· 'Just the 8 pins on their own
········ ENDIF
····· ENDIF··· ' End of this loop
· ENDIF
'
·· PinNum = TempNum········· ' Final Pin#
·· BoardNum = ( Neon - 1 )/25· ' Find Board# subroutine
'
' Find Chip# Subroutine
'
··· ChipNum = (Neon-1)/8
··· ChipNum = ChipNum + BoardNum
RETURN····· ' END of CBP#Calculator
i have also been unable to find any documentation of the syntax for the logical (<, >, >=, etc.) operators anywhere in the help guide or the stamp 2p manual.·
· SELECT neon
··· CASE·100
····· tempNum = 0
··· CASE·75 TO 99
····· tempNum = neon - 75
····CASE·50 TO 74
····· tempNum = neon - 50
····CASE·25 TO 49
····· tempNum = neon - 25
··· CASE·ELSE
····· tempNum = neon
· ENDSELECT
There are other methods in PBASIC (you could do some trikery with LOOKDOWN), but this solution, I think, is the most straightforward.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
· tempNum = neon // 25
That's better, isn't it?· I love the modulus operator!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax