By Mafcase
Champion (258)
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)?
By gdx
Enlighted (6436)
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 (6092)
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 (1126)
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
06-01-2022, 10:14
Ah, eric, I bothered to remove the spaces whereas they don't interfere. :LoL:
06-01-2022, 12:05
Nice! Thank you all for your quick answers...
Don't you have an account yet? Become an MSX-friend and register an account!
Register now