@Josep Roca, about Afx/CVar.inc

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

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

Postby adeyblue » Dec 13, 2020 4:09

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.
Posts: 1230
Joined: May 27, 2005 7:15
Location: FRANCE

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

Postby SARG » Dec 13, 2020 8:59

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.

Return to “General”

Who is online

Users browsing this forum: albert and 11 guests