0

Hi people!
I have a small issue with the MID$ command.
If I put a semi-colon in the source-string then I get the compiler error: Unbalanced Parenthasis!
Also if I do the next (which I need in my program) I get an error message:Code:DIM DisplayTekst AS STRING * 20 DIM OffsetNeg AS BIT DisplayTekst = "OFFSET=_" + MID$ (";", OffsetNeg + 1, 1)
Code:DisplayTekst = "OFFSET=_" + MID$ (":;", OffsetNeg + 1, 1)
But if I swap the colon and semi-colon, I get no error message!
Code:DisplayTekst = "OFFSET=_" + MID$ (";:", OffsetNeg + 1, 1)
The PIC I use is the 16F1829
Compiler version 3.5.9.9
Best regards,
Frizie
www.picbasic.nl
[FONT=Arial][SIZE=2][I][COLOR=navy]Ohm sweet Ohm :cool: [URL="http://www.picbasic.nl"]www.picbasic.nl[/URL][/COLOR][/I][/SIZE][/FONT]
Thumbs Up |
Received: 100 Given: 136 |
While the compiler may have a tiny bit of a parsing issue, if you keep things simple your code will be more readable and the compiler will do what you want. Just my opinion, no criticism intended.
I assumed, possibly wrongly, that OffsetNeg was a byte not a bit. Compiles OK with 3.6.0.3Code:Device = 16F1829 Dim DisplayTekst As String * 20 Dim OffsetNeg As Byte OffsetNeg = OffsetNeg - 1 DisplayTekst = "OFFSET=_" + Mid$(";", OffsetNeg, 1) OffsetNeg = OffsetNeg + 1 DisplayTekst = "OFFSET=_" + Mid$ (":;", OffsetNeg, 1)
George
Thanks for reply George.
But 'OffsetNeg' is a bit, not a byte.
The bit will be TRUE when a offset temperature comes under 0 degrees Celsius, then it haves to place a minus character before the temperature on a 7-segments display.
With MID$ I make the decision, if the 'OffsetNeg' bit is FALSE then take the ":" (which stays for a blanc display, all of the 7-segment LED's from the display in front of the temperature displays will not lit).
If the 'OffsetNeg' bit is TRUE, then it takes the ";", this stays for the minus character (segment 'g' will lit).
Why : and ;?
Coincidence!
The alphanumeriek characters (A-Z and 0-9 and some other characters) stays as ASCII value in a LDATA list.
":" stays for a blanco display
";" stays for the minus
"=" stays for (indeed) the equal sign
"@" stays for the degrees character °
"<" stays for [
">"stays for ]
The characters above (<>@?=:; etc.) are the ASCII characters which stays between the 0-9 and A-Z, but I can not display a @ or a ; on a 7-segment display.
But it goes too far to explain the whole program here and why I have thing done, believe me, it has it's reason.
I just wanted to report the small issue from the compiler-error Unbalanced Parenthasis!.
I have solved the problem for myself to swap the minus character with another 7-segment character in the LDATA list.
Anyway, thanks for replay.
[FONT=Arial][SIZE=2][I][COLOR=navy]Ohm sweet Ohm :cool: [URL="http://www.picbasic.nl"]www.picbasic.nl[/URL][/COLOR][/I][/SIZE][/FONT]
Thumbs Up |
Received: 100 Given: 136 |
Hey, each to his own but if I want to make a simple decision I use "IF".
MID$ is a string handling function, if used in the way that you have I suspect the error text is meaningless.
George
George, the only reason I opened this thread is to report the compiler issue with "Unbalanced parenthasis!", not for solving a program problem I should have (I have solve it directly by swapping 2 characters in a LDATA list).
You're right if the example above was the only thing, ofcourse a simple thing like that you can do it with the IF statement.
But it's not the only string thing in the routine, I filtered all the stuff from my program away here to make the compiler issue "Unbalanced parenthasis! "more clearer here.
What I mentioned earlier: "it goes too far to explain the whole program here and why I have things done, believe me, it has it's reason."
[FONT=Arial][SIZE=2][I][COLOR=navy]Ohm sweet Ohm :cool: [URL="http://www.picbasic.nl"]www.picbasic.nl[/URL][/COLOR][/I][/SIZE][/FONT]
Thumbs Up |
Received: 100 Given: 136 |
Fair enough
George
There are currently 1 users browsing this thread. (0 members and 1 guests)
Actions : (Set Date)
You do not have permission to view the list of names.