autocast of numeric values when string are involved

Share your advanced PureBasic knowledge/code with the community.
User avatar
Zebuddi123
Enthusiast
Enthusiast
Posts: 796
Joined: Wed Feb 01, 2012 3:30 pm
Location: Nottinghamshire UK
Contact:

autocast of numeric values when string are involved

Post by Zebuddi123 »

For those who have not noticed one of the latest additions in 5.10b1

Added: autocast of numeric values when string are involved, allowing to concatenate string and numeric in constants

Very usefull and great addition

Code: Select all

b=10 : a$="a"
Debug a$+b ;  =  a 10

#b=100
#b$="cool"
#a$=#b$+#b
Debug #a$ ; = cool100

; but #a$=#b+#b$ doesnt work
Zebuddi. :D
malleo, caput, bang. Ego, comprehendunt in tempore
jassing
Addict
Addict
Posts: 1885
Joined: Wed Feb 17, 2010 12:00 am

Re: autocast of numeric values when string are involved

Post by jassing »

Zebuddi123 wrote:Added: autocast of numeric values when string are involved, allowing to concatenate string and numeric in constants
I always liked strong typing, it makes it absolute what you want to do.
Imaging you are concatenating strings -- but you type "Amount" instead of "Amount$" which may contain very different values -- you wouldn't get a compiler error, and debugging might be harder...
User avatar
Zebuddi123
Enthusiast
Enthusiast
Posts: 796
Joined: Wed Feb 01, 2012 3:30 pm
Location: Nottinghamshire UK
Contact:

Re: autocast of numeric values when string are involved

Post by Zebuddi123 »

yes true. but i dislike .s for strings so i allways use $.

Merry Xmas & Happy New year to All

Zebuddi. :D
malleo, caput, bang. Ego, comprehendunt in tempore
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: autocast of numeric values when string are involved

Post by netmaestro »

; but #a$=#b+#b$ doesnt work
That's just a bug, Fred's on it. It will work soon.
BERESHEIT
Post Reply