Menu

Character constants....

Help
2008-03-05
2013-05-30
  • Chris Hellyar

    Chris Hellyar - 2008-03-05

    Hi-ho,

    I'm working on my first project using gcbasic instead of asm, and discovered an assumption of mine isn't correct.  (Assumptions, the root of all evil!)

    I'm wanting to set a port to be an ASCII character via a subroutine, passing the ASCII character as a parameter to the subroutine.  That all works fine, but when I try to use a constant rather than a variable it's not working as I expected, and I can't find anything obvious in the chm file or online about how to get what I want.

    The compiler sticks in the code for string handling.

    Some code:  (just the bits relevent, lots removed for clarity...)

    This works:
    ------------
      PORTB="A"
    ------------

    As does:
    ------------
      OutChar="A"
      PORTB=OutChar
    ------------

    But this:
    ------------
      SetPort "A"

      sub SetPort (OutChar)
        PORTB = OutChar
      end sub
    ------------

    Puts the code in for handling a string to pass to SetPort.

    Is there a correct way to do this without using: ?
    ------------
      TempChar="A"
      SetPort TempChar

      sub SetPort (OutChar)
        PORTB = OutChar
      end sub
    ------------

    Cheers, Chris H.

     
    • Hugh Considine

      Hugh Considine - 2008-03-08

      That was a problem with the parameter handling code, which I've now just fixed. Thanks for letting me know.

      The update is at http://gcbasic.sourceforge.net/newfiles . There are 3 files - one which contains an update from 0.9.3.0, one with contains an update from any update after 27/9/2007, and one which has just gcbasic.exe for updating the last patch.

       
      • Nobody/Anonymous

        Thanks for that.

        Wasn't a show-stopper, but did lead to quite a bit of head-scratching. :-).

         

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.