Folderitem.Alias not working ?

  1. 7 months ago

    Richard D

    28 Nov 2019 Xojo Pro Edinburgh, Scotland

    Using the following code on a Mac running MacOS 10.14 and Xojo 2019r2 my test app tells me that my alias is not an alias. The same happens in a version for 2019r1. The file exists, the Finder shows it to be an Alias, the app correctly shows the path to the original item but cannot detect that the Folderitem itself is an Alias. Am I doing something really stupid ?

    Dim f, as FolderItem

    f=SpecialFolder.Desktop.Child("drawing.svg alias")

    MessageBox f.AbsolutePath

    If f.IsAlias Then
    MessageBox("The FolderItem is an alias.")
    Else
    MessageBox("The FolderItem is not an alias.")
    End If

    Child will have resolved the alias so try TrueChild instead.

  2. Kevin G

    28 Nov 2019 Xojo Pro Answer Gatesheed, England

    Child will have resolved the alias so try TrueChild instead.

  3. Richard D

    28 Nov 2019 Xojo Pro Edinburgh, Scotland

    Yes, I was doing something stupid, thank you very much.

  4. Horst J

    16 Dec 2019 Testers, Xojo Pro Europe, Germany, Stuttgart

    In 2019R3 with macOS 10.14.6 it doesn't work anymore.

    I have created an alias of "Microsoft Excel.app" into "/Applications/MS Office" as "Microsoft Excel Alias".

    var f as FolderItem
    f = SpecialFolder.Applications.Child("MS Office").Child("Microsoft Excel Alias")

    If f.IsAlias Then
    MessageBox("The FolderItem is an alias.")
    Else
    MessageBox("The FolderItem is not an alias." + " " + f.NativePath)
    End If

    You get this:
    The FolderItem is not an alias. /Applications/MS Office/Microsoft Excel Alias

    This is from the "Language Reference" for FolderItem
    Notes
    Shortcuts and aliases are resolved on all platforms.

    And if you search for TrueChild you can see:
    This item was deprecated in version 2019r2.
    Please use FolderItem.Child as a replacement.

  5. Dave S

    16 Dec 2019 San Diego, California USA

    first off... does WINDOWS think it is an alias? (that is outside of Xojo)
    second.... what does f.EXISTS say?

  6. Horst J

    16 Dec 2019 Testers, Xojo Pro Europe, Germany, Stuttgart

    if f.Exists then
    MessageBox("The FolderItem exists")
    else
    MessageBox("The FolderItem doesn't exists")
    end if

    Shows:
    The FolderItem doesn't exists

  7. Dave S

    16 Dec 2019 San Diego, California USA

    @Dave S first off... does WINDOWS think it is an alias? (that is outside of Xojo)?

    perhaps you alias is malformed

  8. Jürg O

    16 Dec 2019 Testers, Xojo Pro

    @Horst J And if you search for TrueChild you can see:
    This item was deprecated in version 2019r2.
    Please use FolderItem.Child as a replacement.

    Right. Look at the Documentation for FolderItem.Child .

    FolderItem.Child(Name as String, followAlias as Boolean = True) As FolderItem

    So: Child("Microsoft Excel Alias", False) should not follow the Alias.

  9. Thomas R

    16 Dec 2019 Europe, France, Besancon

    FolderItem.TrueChild(xxx") has to be replaced by FolderItem.Child("xxx", False) ' Get the alias itself
    and
    FolderItem.Child(xxx") has to be replaced by FolderItem.Child("xxx", True) ' Get the target of the alias

  10. Horst J

    16 Dec 2019 Testers, Xojo Pro Europe, Germany, Stuttgart

    No, if I double click it in Finder Excel is starting. The Aliases was renamed in Finder (Alias was removed from file name).

    sh-449:MS Office mcjehle$ ls -al
    total 176
    drwxr-xr-x@ 10 user admin 320 16 Dez 20:15 .
    drwxrwxr-x+ 243 root admin 7776 16 Dez 20:15 ..

    • rw-r--r--@ 1 user admin 6148 16 Dez 19:03 .DS_Store
    • rw-r--r--@ 1 user admin 0 12 Nov 2018 Icon?
    • rw-r--r--@ 1 user admin 768 16 Dez 19:04 Microsoft Excel
    • rw-r--r--@ 1 user admin 844 16 Dez 19:35 Microsoft OneNote
    • rw-r--r--@ 1 user admin 828 12 Nov 2018 Microsoft Outlook
    • rw-r--r--@ 1 user admin 844 16 Dez 19:41 Microsoft PowerPoint
    • rw-r--r--@ 1 user admin 824 16 Dez 19:41 Microsoft Word

    sh-449:MS Office mcjehle$ pwd
    /Applications/MS Office

    But, when I use this:
    f = SpecialFolder.Applications.Child("MS Office").Child("Microsoft Excel Alias", false)
    The alias was detected, when the name of the file ends with "Alias"

    drwxr-xr-x@ 10 user admin 320 16 Dez 20:15 .
    drwxrwxr-x+ 243 root admin 7776 16 Dez 20:15 ..

    • rw-r--r--@ 1 user admin 6148 16 Dez 19:03 .DS_Store
    • rw-r--r--@ 1 user admin 0 12 Nov 2018 Icon?
    • rw-r--r--@ 1 user admin 768 16 Dez 19:04 Microsoft Excel Alias
    • rw-r--r--@ 1 user admin 844 16 Dez 19:35 Microsoft OneNote Alias
    • rw-r--r--@ 1 user admin 828 12 Nov 2018 Microsoft Outlook Alias
    • rw-r--r--@ 1 user admin 844 16 Dez 19:41 Microsoft PowerPoint Alias
    • rw-r--r--@ 1 user admin 824 16 Dez 19:41 Microsoft Word Alias
  11. Jürg O

    16 Dec 2019 Testers, Xojo Pro

    @Horst J But, when I use this:
    f = SpecialFolder.Applications.Child("MS Office").Child("Microsoft Excel Alias", false)
    The alias was detected, when the name of the file ends with "Alias"

    just as expected. And yes, since you're looking for a file named Microsoft Excel Alias, it obviously needs to "end with 'Alias'" :)

    @Horst J The Aliases was renamed in Finder (Alias was removed from file name).

    Then it's expected that .Child("Microsoft Excel Alias", false) will not find it, since there is no such file with filename Microsoft Excel Alias there.

  12. Horst J

    16 Dec 2019 Testers, Xojo Pro Europe, Germany, Stuttgart

    This was only an example. I have a window where I can drop a file or an Alias and this will not work, because the dropped item is the real folderitem (/Applications/Microsoft Excel.app) not the alias "/Applications/MS Office/Excel Alias".

    So I try to read all files from folder "/Applications/MS Office" and this works now:

    var ms as FolderItem
    ms = SpecialFolder.Applications.Child("MS Office")

    If ms.Exists and ms.IsFolder Then
    for i as integer = 0 to ms.Count-1

    var f as new FolderItem
    f = ms.ChildAt(i, false)

    if f.IsAlias then
    Listbox1.AddRow(f.NativePath)
    end if
    next
    end if

    But if I use FileListMBS it doesn't work. Many it is the same problem like "Drop an alias".

    var ms as FolderItem
    ms = SpecialFolder.Applications.Child("MS Office")

    If ms.Exists and ms.IsFolder Then
    var MyFolderList as FileListMBS
    MyFolderList = new FileListMBS(ms)
    var c as integer = MyFolderList.Count-1
    Listbox1.RemoveAllRows

    for i as integer = 0 to c
    var f as new FolderItem
    var n as string
    n = MyFolderList.item(i).Name
    f = ms.Child(n, false)

    if f.IsAlias then
    Listbox1.AddRow(f.NativePath)
    end if
    next
    end if

  13. Emile S

    16 Dec 2019 Europe (France, Strasbourg)

    @Richard D 2019r2

    Xojo 19r2.1 or better (Xojo 19r3 if possible) exist and you better use it (the one you choose).

  14. Horst J

    17 Dec 2019 Testers, Xojo Pro Europe, Germany, Stuttgart

    Yes, I know and I have done these test with R3.

or Sign Up to reply!