@Josep Roca, about Afx/CVar.inc

General FreeBASIC programming questions.
adeyblue
Posts: 300
Joined: Nov 07, 2019 20:08

Re: @Josep Roca, about Afx/CVar.inc

Post by adeyblue »

Go for it. If the string isn't a number you get exactly the same behaviour as not allowing it. If it is, the expected operation happens

Although, I think VarAdd & VarSub convert the string to a number with LOCALE_USER_DEFAULT. So you'll get differing results for a sum like cVar + "1,08" depending on what kind of separator , is in the current locale, if any.
SARG
Posts: 1763
Joined: May 27, 2005 7:15
Location: FRANCE

Re: @Josep Roca, about Afx/CVar.inc

Post by SARG »

Josep Roca wrote:I never occurred to me to test the implemented operators substracting an string from a number.

Should I remove the checks?
My advice is to be coherent : equivalent operators must give the same results eg : v1 += X and v1 = v1 + X
And the same for all the operations of the same kind eg : '+ , - , *, etc..'
So users will not be surprised depending the way they code.

I'm not familiar with variants and I don't use them so it's up to you.
Post Reply