Today 11:49
Forum: The Lounge
Starter: yvesmazzon
Views: 0
Replies: 11
Today 08:42
Forum: Proton 24
Starter: charliecoultas
Views: 0
Replies: 2
+ Reply to Thread
Results 1 to 6 of 6

Thread: Issue with MID$35 days old

  1. #1
    Member Frizie's Avatar
    Join Date
    Apr 2003
    Posts
    174
    Thumbs Up
    Received: 1
    Given: 1
    Total Downloaded
    94.93 MB

    0 Not allowed!

    Question Issue with MID$

    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!

    Code:
    DIM DisplayTekst    AS STRING * 20
    DIM OffsetNeg       AS BIT
    
    DisplayTekst = "OFFSET=_" + MID$ (";", OffsetNeg + 1, 1)
    Also if I do the next (which I need in my program) I get an error message:

    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]

  2. #2
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    1,301
    Thumbs Up
    Received: 50
    Given: 117
    Total Downloaded
    2.36 GB

    0 Not allowed!

    Default Re: Issue with MID$

    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.

    Code:
    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)
    I assumed, possibly wrongly, that OffsetNeg was a byte not a bit. Compiles OK with 3.6.0.3
    George

  3. #3
    Member Frizie's Avatar
    Join Date
    Apr 2003
    Posts
    174
    Thumbs Up
    Received: 1
    Given: 1
    Total Downloaded
    94.93 MB

    0 Not allowed!

    Default Re: Issue with MID$

    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]

  4. #4
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    1,301
    Thumbs Up
    Received: 50
    Given: 117
    Total Downloaded
    2.36 GB

    0 Not allowed!

    Default Re: Issue with MID$

    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

  5. #5
    Member Frizie's Avatar
    Join Date
    Apr 2003
    Posts
    174
    Thumbs Up
    Received: 1
    Given: 1
    Total Downloaded
    94.93 MB

    0 Not allowed!

    Default Re: Issue with MID$

    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]

  6. #6
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    1,301
    Thumbs Up
    Received: 50
    Given: 117
    Total Downloaded
    2.36 GB

    0 Not allowed!

    Default Re: Issue with MID$

    Fair enough
    George

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Problem with MID$ - need help
    By xldaedalus in forum Proton Plus Compiler v3
    Replies: 5
    Last Post: 9th August 2016, 22:28
  2. Lib manager and mid point
    By Tim in forum Proton Plus Compiler v3
    Replies: 1
    Last Post: 3rd August 2010, 20:24

Members who have read this thread since 22nd October 2017, 23:09 : 0

Actions :  (Set Date)  (Clear Date)

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts