PDA

View Full Version : Numbrr to increasing string



Lionheart008
24-02-2024, 19:28
Hello ...

I have Made a little example with increasing number and autoconverts to a String but found perhaps a Bug?



'---Script created on 02-24-2024 17:49:57 by lionheart
'
'
uses "ui"
long flag = 10
flag++
msgbox str$(flag) '11
'thinbasic result 10 ?
'
' number to an increasing string
'
'1)
string s = "200"
s = val(s)+1 '201
msgbox s 'result: "201"
'thinbasic result: 2001

'2)
long k
k++
s = val(s)+k
msgbox s 'result: "202"
'thinbasic result : 2001

'3)
string m = " Mona"
string st = "3000 " + m
st = val(st)+1
msgbox st + m 'result: 3001 Mona
'thinbasic result: 30001

'4)
long km = 100
km++
string m =" Mona"
string sr ="3000 " + m
sr = val(sr) + val(km)+1
msgbox sr + m 'result: 3102 Mona
'thinbasic result: 30001001

ErosOlmi
26-02-2024, 21:19
First of all, thanks for testing, it is always usefull.

To me all exposes cases are as expected.

++ is not supported by thinBasic, at the moment it is just ignored.
All the other cases ... if thinBasic expects a string, math is for string so + is considered "concatenation" even if before there is a VAL

If you need to sum a number into to a string that represent a number, use a numeric variable as destination like:

long n
string s = "200"
n = val(s)+1
msgbox 0, n

Which math to follow (numeric + or + as string concatenation) depends by the destination type