XojoScript Returns Incorrect Values (BUG) 2014r2

From Real Studio 2011 through Xojo 2014 r1.1, the following demo script executes properly without warning and returns a value of 196.

Xojo 2014 r2 prompts an error then continues to process the equation, only returns an incorrect value (200)

Dim x as string 
x = Input("myvalue")
print str(200 - val(x))

Input is set from the XojoScript.Input method (value is 4), and Print simply displays the output via MessageBox.

Before I post a bug report, can anyone else confirm this bug? I’m assuming its a bug because the latest release is the only version to differentiate and cause issues.

Here’s the source to the demo:

http://www.xojodevspot.com/demos/xojoscriptbug.xojo_binary_project

I get 2 MSGBoxes

  1. Error at line: 3
  2. 200

OK…There is a bug for sure then, because XojoScript is not handling Int32/Double values correctly.

When the code runs it should end up looking like this internally:

Dim x as string 
x = "4"
print str(200 - val(x))

In essence, XojoScript is saying that you cannot subtract a double value from the integer value of 200. Hope this is fixed in the next release…it could potentially be a complete show-stopper for those using XojoScript.

No, because if you use this:

Dim x as string x = Input("myvalue") print x

The return is null. There’s nothing there. Something with the input is not right.

And you’re right… something is not correct.

Dim a as string dim b as integer a= "4" b = 200 - val(a) print str(b)

changing b to integer, double or whatever shows two errors for line 4; however, line 5 still prints the correct results.

Also, I haven’t used xojoScript enough to know if the input thing is a bug or not. Somebody may want to check that as well…

Then there’s 2 bugs in XojoScript.

It’s warning about Int32->Double and Input is not working at all.

If it works in every version of Real Studio through the very most recent version of Xojo, only to break in 2014r2, most likely it is a bug.

I only noticed the bugs when attempting to recompile a client piece of software, only to find that it didn’t function at all they way it was intended. (Worse was waiting for this release to fix past bugs) :-/

I agree Input does not seem to work at all and returns an empty string.

The warnings are correct, if unintuitive. The compiler:

  • sees the binary subtraction operator, the operand types being Int32 and Double (the return type of Val)
  • computes that the common type of Int32 and Double is Double
  • converts 200 to a Double, triggering a conversion warning
  • performs the subtraction, yielding a Double
  • sees the assignment operator, the right hand side being a Double and the variable’s type being Int32
  • converts the right hand side to an Int32, triggering a conversion warning
  • stores the Int32 into variable ‘b’

This is a bug. Please file a report in Feedback.

[quote=108245:@Joe Ranieri]The warnings are correct, if unintuitive. The compiler:

  • sees the binary subtraction operator, the operand types being Int32 and Double (the return type of Val)
  • computes that the common type of Int32 and Double is Double
  • converts 200 to a Double, triggering a conversion warning
  • performs the subtraction, yielding a Double
  • sees the assignment operator, the right hand side being a Double and the variable’s type being Int32
  • converts the right hand side to an Int32, triggering a conversion warning
  • stores the Int32 into variable ‘b’

This is a bug. Please file a report in Feedback.[/quote]

Thanks Joe! I figured I’d ask the community before filing a bug report. I thought maybe I missed a change to the way XojoScript handles inputs.

Feedback Posted:
https://xojo.com/issue/34351