If value = "true" working on Mac but not on PC

  1. last week

    I have the following code that is acting differently on the Mac then on a PC.

        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
        

    What's up with that?

  2. Richard G

    May 17 Pre-Release Testers, Xojo Pro Atlanta, GA
    Edited last week by Richard G

    What happens if you test

    IF d.Value("filePathValid") = True Then

    Take off the quotes on True

  3. Wayne G

    May 17 Pre-Release Testers, Xojo Pro New Zealand axisdirect.nz

    With Windows 10 using 2017R1.1 I get "tested true" both with and without the quotes. I am guessing that d is a classic dictionary?

  4. 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...

        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

    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.

  5. Greg O

    May 18 Xojo Inc Somewhere near Raleigh, NC

    Just out of curiosity... is the value actually "true" or True when running on Windows?

  6. 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...

        MsgBox d.Value("filePathValid") 
        
        IF d.Value("filePathValid") = "Valid" Then
          htmlViewer_Document.URL = "http://"+Host+"/"+d.Value("filePath") 
        else
          MsgBox "Invalid Path"
        end If

    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.

  7. Tim H

    May 18 Pre-Release Testers Portland, OR USA
    Edited last week by Tim H

    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?

  8. 7 days ago

    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.

    Thanks to all.

  9. Tim H

    May 19 Pre-Release Testers Portland, OR USA

    You might consider using ReplaceLineEndings before you parse, so it won't matter where the string originated.

  10. 6 days ago

    Greg O

    May 20 Xojo Inc Somewhere near Raleigh, NC

    @John B 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...

        MsgBox d.Value("filePathValid") 
        
        IF d.Value("filePathValid") = "Valid" Then
          htmlViewer_Document.URL = "http://"+Host+"/"+d.Value("filePath") 
        else
          MsgBox "Invalid Path"
        end If

    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.

    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.

  11. Michel B

    May 20 Pre-Release Testers, Xojo Pro

    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.

  12. Greg O

    May 20 Xojo Inc Somewhere near Raleigh, NC

    @Michel B 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.

    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.

or Sign Up to reply!