I assume it is as display error, but as I can’t debug on the live server I don’t know yet how to test this. I believe it must be something with period and comma (so locale settings).
Thank you for you help. It seems to be related to my JSONs and/or CURL somehow running differently locally or when run from the remote server. I have to dive into that deeper.
Getting closer to it. The MBS plugins are not the root cause. I found the same “behavior” in a part of code, where I’m reading directly from a postgres Database. I’m using the same remote Database when debugging locally and when the code is running on the server. Locally I have an SSH connection to connect to the remote database.
This code
var items(-1) as string
items = iDrive.split( chr(9) )
var percentage as double = items(3).left(items(3).Length - 1).ToDouble
messageBox( percentage.ToString)
I changed the “debugging test code” to the following:
var items(-1) as string
items = iDrive.split( chr(9) )
var test as integer = items(3).length
messageBox( test.ToString + " | " + items(3) )
var percentage as double = items(3).left(items(3).Length - 1).ToDouble
I would have expected that there is something wrong with the period in the percentage (74,93%), but running the above code locally, I do get:
i suspect a bug here. it seems very odd that parsing moves the “.” 2 points to the right.
It could be that the .Length is different ?
var items(-1) as string
items = iDrive.split( chr(9) )
var percentage as double = items(3).left(items(3).Length - 1).ToDouble
messageBox( percentage.ToString)
Can you log (on the server):
items(3).Length ?
items(3) the value ?
the percentage (as string) ?
Those combined in a messagebox and a screenshot should show an issue i guess.
var testStr as string = items(3)
var testLength as integer = items(3).length
var percentage as double = items(3).left(items(3).Length - 1).ToDouble
var percentStr as string = percentage.ToString
var percentlength as integer = percentStr.length
messageBox( testStr + "|" + testLength.ToString + "|" + percentStr + "|" + percentlength.tostring )
lenght is different… That’s your issue.
Not sure if this is a bug, but i could be encoding …
Try to
var testStr as string = items(3)
testStr = testStr.DefineEncoding(Encodings.UTF8)
var testLength as integer = items(3).length
var pre_double As String = items(3).left(items(3).Length - 1)
var percentage as double = pre_double.ToDouble
var percentStr as string = percentage.ToString
var percentlength as integer = percentStr.length
messageBox( testStr + "|" + pre_double + "|" + testLength.ToString + "|" + percentStr + "|" + percentlength.tostring )
Try the above, it will output the actual string before it parses it to a double.
Please show the output of both platforms
It’s ofcourse normal that the length shows longer since there are two additional “00” in the string.
I see the base string lenght is “6” which is both correct. Not sure where to go here.
Same output as above, it is not the encoding :-(. Funny enough (when replacing the comma by a period, it doesn’t change the overall behavior either). I added a Replace-Statement:
var percentage as double = items(3).replaceAll(",",".").left(items(3).Length - 1).ToDouble
var testStr as string = items(3)
testStr = testStr.DefineEncoding(Encodings.UTF8)
var testLength as integer = items(3).length
var pre_double As String = items(3).left(items(3).Length - 1)
var percentage as double = pre_double.ToDouble
var percentStr as string = percentage.ToString
var percentlength as integer = percentStr.length
messageBox( testStr + "|" + pre_double + "|" + testLength.ToString + "|" + percentStr + "|" + percentlength.tostring )
I still suspect the SSH connection (locally) versus running the webApp remotely, but I don’t know how to debug that or how to tackle this problem. This is the code bit for the SSH connection:
Var cmd As String = "ssh -o ConnectTimeout=15 MyConnectionStr -L 5432:127.0.0.1:5432 -N -v &"
sshshell.Execute(cmd)
I think this is a bug in the linux .ToString extention for Double values… That would cause serious problems. @Greg_O_Lone care to verfify if this could be the cause?
For localized number formatting, use the ToDouble function instead. Generally, you will use Val for converting internal data and use ToDouble for converting data for input and output of user data.
Indeed! That’s why I’m so curious to know. It seems BTW to be the same for currency conversion. I was only too shy probably: as a user of non US regional formats you are getting used to conversion issues and most of the time it is my fault, but this one really drives me nuts.