-
Syntax Question
Hi I'm just learing the Basics here.. sorry if these questions seem too easy for you smarties out there....
1.
I can't explain why I can not assign a string of text to a variable... eg
MyText VAR BYTE ' Assign the Variable
MyText = "X" ' Place Letter X into MyText
Above compiles Ok.. But,
MyText VAR BYTE[5] ' Assign the Variable
MyText = "HELLO" ' Place Text 'HELLO' into MyText
Doesn't compile. Any Ideas???
2.
If I use SERIN2 to get a line of serial data into an array, is each character stored in the array as one string (like in a LOOKUP table), or as a group seperate elements?
eg
MyText VAR BYTE
SERIN2 PININ, 188, [STR MyText\5]
MyText = "HELLO" OR "H","E","L","L","O"
Thanks if you can help
-
Aw c'mon folks... somebody else answer some questions for a change...
PBP doesn't handle strings... unless they're one byte long... so you have to be creative.
1. Assigning a longer string...
MyText var byte [5]
MyText[0]="H"
MyText[1]="E"
MyText[2]="L"
MyText[3]="L"
MyText[4]="O"
2. Serin will save to an array if you so tell it to. The result will be as per my example in 1 above.
Melanie
-
How about using a binary number? How many bits can be allocated to a Constant? I know that there are 8 bits in a byte.
I would like to use 10 bits if it works.
eg
MyNumber_0 CON %0000000111
MyNumber_128 CON %1111111000
Seems to compile ok.
Would it work? I am using a 16F628 which is an 8 bit controller, but has 2048x14 program space....or doesn't matter because PBP compilies for 8 bits only? Your advice is much appreciated.
-
If you spill out of eight bits then it becomes a word and you have up to sixteen bits to play with.
Remember, you have three types of data element to play with, a bit, a byte and a word. Whatever you're doing must fit one of these.
Melanie