Is there a way to concat/merge/join vars in MSX basic?

By Mafcase

Master (256)

Аватар пользователя Mafcase

06-01-2022, 01:15

Is there a way to concat/merge/join vars in MSX basic?

Example:

A = 2
B = 3

I would like to know if there is a way I can get C to be 23 (C = AB)?

Для того, чтобы оставить комментарий, необходимо регистрация или !login

By gdx

Enlighted (5831)

Аватар пользователя gdx

06-01-2022, 02:28

A=2: B=3: C=A*10+B

or

A=2: B=3: A$=STR$(A): B$=STR$(B): C=VAL(RIGHT$(A$,LEN(A$)-1)+RIGHT$(B$,LEN(B$)-1))

It doesn't work with negative values, and first way work if B is a number of one digit only.

By NYYRIKKI

Enlighted (5972)

Аватар пользователя NYYRIKKI

06-01-2022, 05:15

Your goal is not mathematically valid, so I guess this answer is just as good as any else:
DEFSTRC:C=OCT$(A)+OCT$(B)

(As gdx suggested, C=A*10+B is the correct answer)

By ericb59

Paragon (1087)

Аватар пользователя ericb59

06-01-2022, 09:45

10 a=2:b=3
20 aa$=STR$(A)
30 bb$=STR$(B)
40 c$=AA$+BB$
50 C=VAL(C$)
60 PRINT C

run
23

By gdx

Enlighted (5831)

Аватар пользователя gdx

06-01-2022, 10:14

Ah, eric, I bothered to remove the spaces whereas they don't interfere. :LoL:

By Mafcase

Master (256)

Аватар пользователя Mafcase

06-01-2022, 12:05

Nice! Thank you all for your quick answers... Smile