forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Bug in VDS 5?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Bug Reports
View previous topic :: View next topic  
Author Message
Aslan
Valued Contributor
Valued Contributor


Joined: 31 May 2001
Posts: 589
Location: Memphis, TN USA

PostPosted: Wed Aug 11, 2004 2:55 pm    Post subject: Bug in VDS 5? Reply with quote

I seem to be having a problem with VDS 5 telling the difference between a (.) and a (0)

Reference:
. = @chr(46)
0 = @chr(48)

Code:
%S = 0. Some sentence here
          If @equal(@chr(46),@substr(%S,1))
           %S = @strdel(%S,1)
          end
Info %S
exit


result %S = . Some sentence here

Code:
%S = .0 Some sentence here
          If @equal(@chr(46),@substr(%S,1))
           If @not(@equal(@chr(48),@substr(%S,1)))
           %S = @strdel(%S,1)
           end
          end
Info %S
exit


result %S = unchanged

The same is true if I use the actual character eg. "." and "0" instead of @chr(46) and @chr(48)

Is this a bug or am I doing something wrong?
Back to top
View user's profile Send private message Send e-mail
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Wed Aug 11, 2004 4:10 pm    Post subject: Reply with quote

I think you are trying to make this point?

Code:
if @equal(0,.)
  warn Bug!
end


Indeed, it seems strange that VDS thinks a zero and a decimal are the
same/equal. Confused

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
Aslan
Valued Contributor
Valued Contributor


Joined: 31 May 2001
Posts: 589
Location: Memphis, TN USA

PostPosted: Wed Aug 11, 2004 4:56 pm    Post subject: Reply with quote

That is exactly my point.

Thank you for the simlification FreezingFire Smile
Back to top
View user's profile Send private message Send e-mail
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Wed Aug 11, 2004 4:59 pm    Post subject: Reply with quote

Looks like a bug. I'll move this to Bug Reports.
_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Wed Aug 11, 2004 6:25 pm    Post subject: Reply with quote

It might not be a bug. I think VDS treats the two arguments as numbers because a dot is the decimalseperator used by VDS: a dot means 0.0 => 0... Rolling Eyes Look at this example:

Code:
option decimalsep,","

  if @equal(0,.)
    warn Bug!
  else
  info Bugfree!?
end

_________________
[ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial!
Back to top
View user's profile Send private message
Tommy
Admin Team


Joined: 16 Nov 2002
Posts: 746
Location: The Netherlands

PostPosted: Wed Aug 11, 2004 6:43 pm    Post subject: Reply with quote

Of course if using Skit's technique there will be another problem:

Code:
  option decimalsep,","

  if @equal(0,",")
    warn Bug!
  else
    info Bugfree!?
  end


A solution is, as I think has been discussed before, to include non-numeric characters
in the comparison like this:

Code:
%a = 0
%b = .
if @equal("x"%a"x","x"%b"x")
  info Variables are equal.
else
  info Variables are unequal.
end
Back to top
View user's profile Send private message Send e-mail Visit poster's website
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Wed Aug 11, 2004 11:05 pm    Post subject: Reply with quote

Tommy wrote:
A solution is, as I think has been discussed before, to include non-numeric characters
in the comparison like this:

Code:
%a = 0
%b = .
if @equal("x"%a"x","x"%b"x")
  info Variables are equal.
else
  info Variables are unequal.
end


Nice workaround. Smile

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
Aslan
Valued Contributor
Valued Contributor


Joined: 31 May 2001
Posts: 589
Location: Memphis, TN USA

PostPosted: Thu Aug 12, 2004 2:19 am    Post subject: Reply with quote

Thanks for all the help guys. You have saved me from alot of work Smile
Back to top
View user's profile Send private message Send e-mail
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Thu Aug 12, 2004 2:24 am    Post subject: Reply with quote

Anyone notice that this wasn't a bug in VDS 4?
_________________
-Sheep
My pockets hurt...
Back to top
View user's profile Send private message Send e-mail
jules
Professional Member
Professional Member


Joined: 14 Sep 2001
Posts: 1043
Location: Cumbria, UK

PostPosted: Thu Aug 12, 2004 11:15 am    Post subject: Reply with quote

I've mentioned it before, as I too have been caught by it. It isn't a bug, it's just due to the fact that VDS tries a numeric comparison first, and does a text comparison second if either of the values turn out to be non-numeric. For some reason, Borland's numeric evaluation code does not consider "." to be non-numeric, but a value of zero. I guess the same would apply to "," in countries where that is a decimal separator.
VDS 4 used older code, which did not properly take account of the system settings for number formats. The change you note will have been a side-effect of correcting this.

_________________
The Tech Pro
www.tech-pro.net
Back to top
View user's profile Send private message Visit poster's website
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Thu Aug 12, 2004 6:03 pm    Post subject: Reply with quote

Hmmmmm...... Bug? Side Effect? Is there really a difference? Laughing
_________________
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
Back to top
View user's profile Send private message
PGWARE
Web Host


Joined: 29 Dec 2001
Posts: 1562

PostPosted: Thu Aug 12, 2004 6:54 pm    Post subject: Reply with quote

I wouldn't call this a bug, Borland made a change to how they recognize numeric digits, they now consider the decimal pointers as numeric. As that is often used in numerical operations with floating point numbers.
Back to top
View user's profile Send private message
jules
Professional Member
Professional Member


Joined: 14 Sep 2001
Posts: 1043
Location: Cumbria, UK

PostPosted: Fri Aug 13, 2004 8:05 am    Post subject: Reply with quote

A bug, to me, is the result of a mistake, an error in coding. I don't consider using the native run-time library routines to determine whether a string is numeric or not is an error in coding.

Unfortunately, with something as complex as VDS, it's almost impossible to change or improve something without affecting code that relied on it working in some specific way that was not actually documented.

_________________
The Tech Pro
www.tech-pro.net
Back to top
View user's profile Send private message Visit poster's website
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Fri Aug 13, 2004 9:10 am    Post subject: Reply with quote

I don't think the @equal(.,0) thing is a bug, but I do consider the next code as one:

Code:
option decimalsep,.

info This does work: @fadd(.,.)
info So does this: @fadd(0,0)
info And while 0 - 0 does work: @diff(0,0)

# It goes wrong with the next line:
info This doesn't: @diff(.,.)

_________________
[ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial!
Back to top
View user's profile Send private message
jules
Professional Member
Professional Member


Joined: 14 Sep 2001
Posts: 1043
Location: Cumbria, UK

PostPosted: Fri Aug 13, 2004 10:02 am    Post subject: Reply with quote

No it's not, because @diff() is meant to work with integers, which should not have decimal points in them. @fsub(.,.) would probably work, as that is the function you're supposed to use for subtracting floating point numbers.
_________________
The Tech Pro
www.tech-pro.net
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Bug Reports All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group