Command
leshea2
Posts: 83
I know that VAR is used to store data, but what is CON used for, for an example·in a·code like this,
' {$STAMP BS2}
' {$PBASIC 2.5}
SO············· PIN···· 1·············· ' serial output
FC············· PIN···· 0·············· ' flow control pin
#SELECT $STAMP
· #CASE BS2, BS2E, BS2PE
··· T1200······ CON···· 813
··· T2400······ CON···· 396
··· T9600······ CON···· 84
··· T19K2······ CON···· 32
··· T38K4······ CON···· 6
· #CASE BS2SX, BS2P
··· T1200······ CON···· 2063
··· T2400······ CON···· 1021
··· T9600······ CON···· 240
··· T19K2······ CON···· 110
··· T38K4······ CON···· 45
· #CASE BS2PX
··· T1200······ CON···· 3313
··· T2400······ CON···· 1646
··· T9600······ CON···· 396
··· T19K2······ CON···· 188
··· T38K4······ CON···· 84
#ENDSELECT
Inverted······· CON···· $4000
Open··········· CON···· $8000
Baud··········· CON···· T38K4 + Inverted
Main:
· DO
··· SEROUT SO\FC, Baud, [noparse][[/noparse]"Hello!", CR]· ' send the greeting
··· PAUSE 2500························· ' wait 2.5 seconds
· LOOP································· ' repeat forever
· END
Thanks !
' {$STAMP BS2}
' {$PBASIC 2.5}
SO············· PIN···· 1·············· ' serial output
FC············· PIN···· 0·············· ' flow control pin
#SELECT $STAMP
· #CASE BS2, BS2E, BS2PE
··· T1200······ CON···· 813
··· T2400······ CON···· 396
··· T9600······ CON···· 84
··· T19K2······ CON···· 32
··· T38K4······ CON···· 6
· #CASE BS2SX, BS2P
··· T1200······ CON···· 2063
··· T2400······ CON···· 1021
··· T9600······ CON···· 240
··· T19K2······ CON···· 110
··· T38K4······ CON···· 45
· #CASE BS2PX
··· T1200······ CON···· 3313
··· T2400······ CON···· 1646
··· T9600······ CON···· 396
··· T19K2······ CON···· 188
··· T38K4······ CON···· 84
#ENDSELECT
Inverted······· CON···· $4000
Open··········· CON···· $8000
Baud··········· CON···· T38K4 + Inverted
Main:
· DO
··· SEROUT SO\FC, Baud, [noparse][[/noparse]"Hello!", CR]· ' send the greeting
··· PAUSE 2500························· ' wait 2.5 seconds
· LOOP································· ' repeat forever
· END
Thanks !
Comments
·· CON is used to define constants.· Values that don't change.· These can replace constant values in your code with meaningful descriptions, also making it easy to make code changes.· If you change the value in the Constant, all uses of it are affected.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Thanks !
But you can do:
DATA String1, "Call 18004459889 at 4:35 P.M.", 0
MyStr VAR WORD
MyByte VAR BYTE
MAIN:
MyStr = String1
GOSUB OutputString
Pause 100
GOTO MAIN
OutputString:
READ MyStr, MyByte
DO WHILE·MyByte <> 0
SEROUT 16, 16384, [noparse][[/noparse]MyByte]
MyStr = MyStr + 1
READ MyStr, MyByte
LOOP
RETURN
MyStr = MyStr + 1
READ MyStr, MyByte
Thanks !
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
MyStr = MyStr + 1
READ MyStr, MyByte,
if I wanted to end the code at
SEROUT 16, 16384, [noparse][[/noparse]MyByte], ?
Thanks !
"MyByte" then gets the value of the BYTE (a single byte) with each READ.
Then the single byte is output, using the SEROUT command.
This process repeats, until MyByte is loaded with that 'zero' value at the end of the string.
If you don't want to output the entire string, and want to output only the first byte, then certainly you can end the code after the SEROUT. But a single byte string, like "C", is not very useful when you wanted to output "Call ..."