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

Par Mafcase

Master (255)

Portrait 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)?

!login ou Inscrivez-vous pour poster

Par gdx

Enlighted (5514)

Portrait 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.

Par NYYRIKKI

Enlighted (5923)

Portrait 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)

Par ericb59

Paragon (1071)

Portrait 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

Par gdx

Enlighted (5514)

Portrait de gdx

06-01-2022, 10:14

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

Par Mafcase

Master (255)

Portrait de Mafcase

06-01-2022, 12:05

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