Conditional Compilation
Newzed
Posts: 2,503
I have a program with two variables, dit and dah, which are expressed in milliseconds.· Is the following Conditional Compilation written correctly:
#SELECT $stamp
#CASE BS2, BS2E, BS2PE
· dit = dit */$0100
· dah = dah */$0100
#CASE BS2P
· dit = dit */$03C4
· dah = dah */$03C4
#CASE BS2px
· dit = dit*/$0605
· dah = dah*/$0605
#ENDSELECT
The above snippet tokenized OK.
Thanks
Sid
#SELECT $stamp
#CASE BS2, BS2E, BS2PE
· dit = dit */$0100
· dah = dah */$0100
#CASE BS2P
· dit = dit */$03C4
· dah = dah */$03C4
#CASE BS2px
· dit = dit*/$0605
· dah = dah*/$0605
#ENDSELECT
The above snippet tokenized OK.
Thanks
Sid
Comments
Question:·Is there any reason to use variables here?· If the Dit and Dah length are designed to be fixed then you could embed those constants into the CC construct -- just a thought if you run short on variable space.
I'm glad to see that someone else is using Conditional Compilation; it's a great tool.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Expected label, variable or instruction
so I converted dit and dah from a constant to a variable and it tokenized OK.· I would rather use constants if there is a way.
Sid
I wrote dit con 50 and dah con 150, and then tried to use the constants dit and dah in the CC.· That;s when I got the error.
Dit and dah are not fixed constants - they can be varied by the user to generate code speeds of 5 to 25 wpm.
Sid
#CASE BS2, BS2E, BS2PE
BSpeed CON $0100
#CASE BS2P
BSpeed CON $03C4
#CASE BS2px
BSpeed CON $0605
#ENDSELECT
dit = dit */ BSpeed
Sid, you might also need a separate statement for the BS2pe and BS2sx. It depends on which command you are using to create the sound. The PAUSE command is the same (1 millisecond units) on every single Stamp in the lineup, so if you key an external sounder, the different Stamp speeds would be a non-issue. On the other hand, the FREQOUT command has a separate period parameter for each Stamp (except BS2 = BS2e).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
That takes care of the dits - what about the dahs?
Would I write dah·= dit * 3
I presume I make dit a constant - dit con 50 - and forget about dah since it defined in the program in terms of dit.
I know about the difference in FREQOUT notes - I just haven't cranked that in yet.
Sid
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com