Shop OBEX P1 Docs P2 Docs Learn Events
+= works weird for strings — Parallax Forums

+= works weird for strings

pik33pik33 Posts: 2,388
edited 2022-02-13 10:23 in BASIC (for Propeller)
dim filename$ as string
filename$="123456"
filename$+=space$(38)
print filename$

It compiles, but:
warning: assignment discards const attribute from pointer
and the result is: �x3��

Standard syntax works as expected: the result is 123456 and 38 spaces at the end.

dim filename$ as string
filename$="123456"
filename$=filename$+space$(38)
print filename$

Comments

  • @pik33 said:

    dim filename$ as string
    filename$="123456"
    filename$+=space$(38)
    print filename$
    

    It compiles, but:
    warning: assignment discards const attribute from pointer
    and the result is: �x3��

    Standard syntax works as expected: the result is 123456 and 38 spaces at the end.

    dim filename$ as string
    filename$="123456"
    filename$=filename$+space$(38)
    print filename$
    

    There were some bugs with handling the temporary strings required for += when the right hand side is a function call. For now either avoid += with strings (except for simple variables and literal strings) or else update to the most recent github source code.

    Thanks for the bug report,

Sign In or Register to comment.