test for parent

I have this code [code]Dim f As FolderItem
f = GetFolderItem("")

If GrList.GrmFName.Parent = f Then[/code]
The file’s GrList.GrmFName.Parent is the same as f but it wouldn’t test
Why doesn’t it work?

your code is testing whether the object (grmfname.parent) is the same Object as f. This sounds logical, but isn’t what you want. You want to see if the folderItem that each object points to is the same.

Try this:

function IsFolderItemSame(f as folderItem, g as folderItem) as boolean
  if f = nil or g = nil then
    return false  ' this is actually undefined behavior
  end if
  if strcomp(f.nativePath,g.nativePath,0) = 0 then
    return true
  else
    return false
  end if
end function

The reason for using strcomp in binary mode 0 is that this way two folders with identical names but different case will show as different (e.g. “FooBar” ? “FOObar”) - this may or may not be how you want it to work.

Thanks. After I wrote my question, I realized what the answer was, but couldn’t explain the pointing.