I have the following code that is acting differently on the Mac then on a PC.
[code] MsgBox d.Value(“filePathValid”)
//on the mac and the PC the msgBox says “True”
IF d.Value("filePathValid") = "True" Then
MsgBox "tested true"
//on the Mac I get here with the MsgBox saying "tested true"
LoadDocument(d)
else
MsgBox "tested false"
//on the PC I get here with the MsgBox saying "tested false"
end If
[/code]
Changed: IF d.Value(“filePathValid”) = “True” Then
To: IF d.Value(“filePathValid”) = True Then
Same result works on Mac not Windows. If it’s not already clear, it works on mac using built standalone web app running on mac. Does not work on windows using built standalone web app running on windows.
Wayne, I’m not sure what you mean by “classic dictionary” and the implications. d is created like this…
[code] Dim d As Dictionary
For each docID As String in session.Documents.Keys
d = session.Documents.Value(docID)
If d.Value("docTitle")=lb_Documents.List(lb_Documents.ListIndex) Then
Exit
End If
Next[/code]
Documents is a Session property dictionary of dictionaries created on session open with…
Dim dcs As New Dictionary
Documents = dcs
Session.Dictionary is loaded from an http request to a database using an XMLReader.
Greg, yes it is actually “True”. The first MsgBox confirms it.
This is really weird. I have changed the value from “True” to “Valid” and simplfied the call to this…
[code] MsgBox d.Value(“filePathValid”)
IF d.Value("filePathValid") = "Valid" Then
htmlViewer_Document.URL = "http://"+Host+"/"+d.Value("filePath")
else
MsgBox "Invalid Path"
end If[/code]
I can build 2 web apps, one for windows and one for mac both pointing to the same database running on the windows machine, so the both are getting the document dictionary from the same source. Using Safari on the Mac in 1 tab I connect to the Windows web app and in a second tab I connect to the Mac web app. The Mac web app works fine, but no matter how I try to test the dictionary value using the windows web app it always tests false.
Does it make a difference if you use an intermediate variable?
Dim filePathValid as String = d.Value("filePathValid")
// msgbox str(len(filePathValid))
// msgbox EncodeHex(filePathValid, true)
IF filePathValid = "Valid" Then
htmlViewer_Document.URL = "http://"+Host+"/"+d.Value("filePath")
else
MsgBox "Invalid Path"
end If
If it fails, make sure there aren’t any extra characters in the data via the msgbox calls. And does the string have a valid encoding?
Thanks Tim. You got me headed in the right direction.
Turns out my xmlReader was testing for end of line with Xojo EndOfLine. Which worked just fine on the xml when received from a mac server. Did not work when coming from a windows server. Changed it to test for EndOfLine.OSX or EndOfLine.Windows.
Interestingly, I really only needed to change it to EndOfLine.OSX. The database running on windows was developed on the Mac and so was passing cr as end of line. The Xojo web app’s EndOfLine with out the type part running on the windows machine was probably expecting CRLF or something similar and so my xmlReader did not handle it properly. Using EndOfLine.OSX fixes it as CR is being returned regardless which machine the database or the Xojo webapp resides.
[quote=331592:@John Baughman]Greg, yes it is actually “True”. The first MsgBox confirms it.
This is really weird. I have changed the value from “True” to “Valid” and simplfied the call to this…
[code] MsgBox d.Value(“filePathValid”)
IF d.Value("filePathValid") = "Valid" Then
htmlViewer_Document.URL = "http://"+Host+"/"+d.Value("filePath")
else
MsgBox "Invalid Path"
end If[/code]
I can build 2 web apps, one for windows and one for mac both pointing to the same database running on the windows machine, so the both are getting the document dictionary from the same source. Using Safari on the Mac in 1 tab I connect to the Windows web app and in a second tab I connect to the Mac web app. The Mac web app works fine, but no matter how I try to test the dictionary value using the windows web app it always tests false.[/quote]
Actually it doesn’t. Variants perform data transformations in all sorts of evil ways, so technically it’s possible that a Boolean TRUE could be passed in and a String “true” be pulled out. My suggestion is to use a class with very specific data types instead of a dictionary.
[quote=331798:@Michel Bujardet]I use dictionary extensively with string values “True” and “False”, and have never, ever, observed the kind of issue reported.
There must be something else at play here.[/quote]
Right. But my point was that using msgbox doesn’t confirm anything. You can put anything into a dictionary and it’ll try to convert it to a string when you pass it to a function that takes a string. Just wanted him to understand that.