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

Por Mafcase

Master (256)

Imagen del 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 sesión o register para postear comentarios

Por gdx

Enlighted (5815)

Imagen del 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 (5970)

Imagen del 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 (1087)

Imagen del 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 (5815)

Imagen del gdx

06-01-2022, 10:14

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

Por Mafcase

Master (256)

Imagen del Mafcase

06-01-2022, 12:05

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