Menu

Why this won't compile

2023-07-29
2023-07-29
  • Harley Burton

    Harley Burton - 2023-07-29

    I got this bit of code and it won't compile. It shows me that there are unbalanced brackets. I don't know why it won't compile. Can anyone tell me what's wrong?

    ' Define segment patterns for 0-9 digits
    DIM DigitPatterns(9) AS BYTE[8] = [ _
    &B00111111,
    &B00000110,
    &B01011011,
    &B01001111,
    &B01100110,
    &B01101101,
    &B01111101,
    &B00000111,
    &B01111111,
    &B01101111
    ]

    Thanks,

    Harley

     
  • Anobium

    Anobium - 2023-07-29

    Hello Harley,

    See https://gcbasic.sourceforge.io/help/_lcdcreatechar.html to create a custom character that uses the array construct.


    ' Define segment patterns for 0-9 digits
    DIM DigitPatterns(9) AS BYTE[8] = [ _
    &B00111111,
    &B00000110,
    &B01011011,
    &B01001111,
    &B01100110,
    &B01101101,
    &B01111101,
    &B00000111,
    &B01111111,
    &B01101111
    ]

     'Create an array to store the character until it is copied
        Dim CharArray(8)
    
        'Set the array to hold the character
        'Binary has been used to improve the readability of the code, but is not essential
        CharArray(1) = b'00011011'
        CharArray(2) = b'00011011'
        CharArray(3) = b'00000000'
        CharArray(4) = b'00000100'
        CharArray(5) = b'00000000'
        CharArray(6) = b'00010001'
        CharArray(7) = b'00010001'
        CharArray(8) = b'00001110'
    
        'Copy the character from the array to the LCD
        LCDCreateChar 0, CharArray()
    
        'Draw the custom character
        LCDWriteChar 0
    

    Another way ... and, there may be more ways . :-)

    Dim CharArray(10) as Byte
        CharArray = 0B00111111, 0B00000110, 0B01011011, 0B01001111, 0B01100110, 0B01101101, 0B01111101, 0B00000111, 0B01111111, 0B01101111 
    
     
  • Anobium

    Anobium - 2023-07-29

    Another way.... looks more like the original...

    Dim CharArray(10) as Byte:  CharArray = _
        0B00111111, _
        0B00000110, _
        0B01011011, _
        0B01001111, _
        0B01100110, _
        0B01101101, _
        0B01111101, _
        0B00000111, _
        0B01111111, _
        0B01101111
    

    Porting from another language can be challenging. :-)

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.