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

Por Mafcase

Champion (258)

imagem de 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)?

Entrar ou registrar-se para comentar

Por gdx

Enlighted (6436)

imagem de 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.

Por NYYRIKKI

Enlighted (6092)

imagem de 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)

Por ericb59

Paragon (1126)

imagem de 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

Por gdx

Enlighted (6436)

imagem de gdx

06-01-2022, 10:14

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

Por Mafcase

Champion (258)

imagem de Mafcase

06-01-2022, 12:05

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