Menu

strings

Help
2007-10-23
2013-05-30
  • Nobody/Anonymous

    I would like to do the following:

    printstring$=  "G:", tmp, "X", tmp2, tmp1, " T:", tmp3, " B:", buffer(3), buffer(2), buffer(1), buffer(0)

    print(printstring$)

    That is concatenate a string. Will the compiler at present do that?
    The variables above contain ascii data. For example, tmp="2", etc.

     
    • kent_twt4

      kent_twt4 - 2007-10-24

      After looking at a few forum posts:
      The sample below will compile (did not test with lcd).  GCBasic doesn't seem to like the buffer()/string, or for that matter variable/string, combos.  You could divide up the statements into inline statements of like groups (i.e. string, integer, string, etc.).  Seems that the way it goes for me anyhow; maybe not elegant looking, but gets the job done.

      Dim buffer(3)
      Dim tmp$ as string
      Dim printstring$ as string
      ...
      ...
      tmp$ = "2"
      'buffer(3) = "3"
      ...
      printstring$= "G:" + tmp$ + "X"  '+ buffer(3)
      print(printstring$)
      ...
      ...

      When buffer(3) is uncommented the following compiler error is noted.

      ---------- Capture Output ----------
      > "C:\Program Files\GCBasic\Compile.bat" C:\PROGRA~1\CRIMSO~1\MCHP-L~1\FORUMS~1
      Great Cow BASIC (0.9 6/10/2007)

      Compiling C:\PROGRA~1\CRIMSO~1\MCHP-L~1\FORUMS~1 ...

      An error has been found:

      Error: Cannot store SysArrayTemp1 in the string variable PRINTSTRING

      The message has been logged to the file C:\PROGRA~1\GCBASIC\ERRORS.txt.

      Press any key to continue

       
    • Nobody/Anonymous

      Thanks for that info. I reported recently that you can't copy one array element to another, for eample: buffer(3)=sbuf(1). In fact the compiler does not even give an error, it just doesn't work. You must copy the array element to an intermediate variable.

       

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.