Menu

String Concatenation

rinthesun
2007-10-24
2013-05-30
  • rinthesun

    rinthesun - 2007-10-24

    I am writing LCD code. I wish to do the following

    tmp=geomy+0x30 'geomy=4 so tmp=0x34="4"
    xstring$="G:"+tmp+"X"+tmp1
    locate(1,0)
    print(xstring$)

    This will give a compiler error. As will the following:

    xstring$="G:"+0x34+"X"

    But the followng works

    xstring$="G:"+"4"+"X"

    The above two are the same, since I know "4"=0x34.

    Why can't the compiler give a warning but continue compilation, assuming that I know what I am doing.

     
    • kent_twt4

      kent_twt4 - 2007-10-24

      Continuation from Help....

      Treat variables and strings like oil and water, and you will be O.K.  To provide some insight, maybe take a look at lcd.h file in the 'low level include folder' of GCBasic.  Looking at the 'sub PRINT (PrintData$)', you can see that unless you have the data in a string format like 4$ or "4" its not going to work.

      This is how I would output your example to the LCD:

      geomy=4  ;defined geomy just so it would compile
      tmp=geomy+0x30 'geomy=4 so tmp=0x34="4"
        ;xstring$="G:"+tmp+"X"+tmp1
      locate(1,0)
      print("G:"): LCDInt(tmp): print("X"): LCDInt(tmp1)

      No help with the error code, but you will run into this a lot (i.e. always makes debugging interesting/frustrating?).

       

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.