A Replace function question...

  1. 5 months ago

    In Xojo IDE for Windows I set

    Dim txtFileName as string = Session.Login + "_" + Session.myPatientName + "_" + d.ShortDate +".txt"

    When compiled, in Windows Chrome gives
    xxx_patient_4_15_2018.txt

    In Chrome Mac, gives
    xxx_patient_4/15/2018.txt which produces an error

    In order to fix, it I add
    txtFileName = Replace(txtFileName, "/", "_")

    And gives
    xxx_patient_4_15/2018 which produces an error,too

    It seems a kind of an Xojo internal bug? or what...?

  2. Markus W

    Apr 15 Pre-Release Testers, Xojo Pro #JeSuisHuman Germany, Heidelb...

    You still have a forward slash (which is the file delimiter on Mac). Use ReplaceAll instead.

  3. Michel B

    Apr 15 Pre-Release Testers RubberViews.com
    Edited 5 months ago

    Instead of relying on d.shortdate, which can be set by the user to pretty much anything, you should format that string yourself.

    Please try when you post code to select it and click the Code -image- icon above the editor like I do below. It is a courtesy to other forum members to offer more legibility.

    Something like this should do :

    Dim txtFileName as string = Session.Login + "_" + Session.myPatientName + "_" + str(d.month)+"_"+str(d.day)+"_"+str(d.year)+".txt"
  4. Olivier C

    Apr 16 Pre-Release Testers, Xojo Pro Europe (Belgium, Brussels)

    as it's for a file name, maybe the mdy format is not important and simply use

    Dim txtFileName as string = Session.Login + "_" + Session.myPatientName + "_" + d.SQLDate + ".txt"
  5. Ian K

    Apr 16 Pre-Release Testers, Xojo Pro

    Equally, if you needs to stick to your format, you could change Replace() function to ReplaceAll().

  6. I had already solved then problem thinking as Michael.
    Appreciate you all, for your nice alternatives!

or Sign Up to reply!