DX script help! Or why is 2 not smaller than 15?

Tuesday, September 28, 2004 by paxx | Discussion: Skinning

OK, somebody explains this to me please...
Say I have this code:

Sub Object_OnScriptEnter
  Object.SetTimer 9882, 5000
  Object.PersistStorage("current") = 0
  Object.PersistStorage("WPNum") = 15
End Sub

Sub Object_OnTimer9882
  If Object.PersistStorage("current") < Object.PersistStorage("WPNum") Then
    msgbox Object.PersistStorage("current") & " is smaller than " & Object.PersistStorage("WPNum")
  Else
    msgbox Object.PersistStorage("current") & " is not smaller than " & Object.PersistStorage("WPNum")
  End If
  Object.PersistStorage("current") = Object.PersistStorage("current") + 1
End Sub

Now, the output of this would be msgboxes like this:
0 is smaller than 15
1 is smaller than 15
2 is not smaller than 15
3 is not smaller than 15
etc.

Now, how is that? There is something I don't understand.  I've already checked that the returned values were numeric with the IsNumeric function, and they are.
I really need help on this please.

_Martin_
Reply #1 Tuesday, September 28, 2004 3:12 PM
You may need to convert to an integer or other numeric data format before performing calculations on it:

If CInt(Object.PersistStorage("current")) < CInt(Object.PersistStorage("WPNum")) Then
paxx
Reply #2 Tuesday, September 28, 2004 3:13 PM
All right. I still don't understand why bit it seems the values are not considered Integers. I used CInt to convert the Persistent Storage variables and it works now.
paxx
Reply #3 Tuesday, September 28, 2004 3:13 PM
Hehehe!  Thanks Martin. We figured it out at the same time.

Please login to comment and/or vote for this skin.

Welcome Guest! Please take the time to register with us.
There are many great features available to you once you register, including:

  • Richer content, access to many features that are disabled for guests like commenting on the forums and downloading skins.
  • Access to a great community, with a massive database of many, many areas of interest.
  • Access to contests & subscription offers like exclusive emails.
  • It's simple, and FREE!



web-wc01