Path problem Tiger/Leopard

Hello All!

I’ve built a small applet and some users (all under Leopard) are reporting a small problem that I can’t explain.

Here the part of the which generates an Error -43 (File wasn’t found.)
Of course I clearly see that the last slash of the dirname part is mangled but I don’t understand why it is missing.


property tmpDir : path to temporary items with folder creation
--
--
set f to "_someVarName.txt"
--
set __hfs_out to (tmpDir & f)) as Unicode text
set __pos_out to POSIX path of __hfs_out
--

--> Result TIGER : "/private/var/tmp/folders.501/TemporaryItems/_someVarName.txt"
--> Result LEO : ""/private/var/folders/4o/4owG0baA2RaztU+BYwMo3++++TM/TemporaryItems_someVarName.txt" -- >> Error -43 (Finder) Can't find file ...

Thank you for your advised opinions!

Clement

Hi Clement,

NEVER use a path to expression in a property.
After creating an applet the value of the property is persistent,
so the value on your machine won’t work very well on other machines.

Always define a relative folder in a set line


set tmpDir to path to temporary items with folder creation
set f to "_someVarName.txt"
--
set __hfs_out to (tmpDir & f) as Unicode text
set __pos_out to POSIX path of __hfs_out

Hi Stefan,

As usual you’'re rigth… and I totaly missed the point.

Thanks to the police :wink: Ordnung muß sein ! Ouch !

Clement

That is a list coercion, which is affected by AppleScript’s text item delimiters. Consider this instead:

set __hfs_out to (tmpDir as Unicode text) & f

Thanks Bruce, I missed that concerning the major problem :wink:

Thanks Bruce. Much obliged.

However and with the risk to appear ridiculous, could you explain me why it is a list coercion.

Regards
Clement

Hi,

"A" & "B"

→ “AB” concatenates two text strings (same class)

"B" & 1

→ “B1” concatenates a string and a number (the number will be coerced to text implicitly)

1 & "B"

→ {1, “B”} results a list (“B” cannot coerced to a number)

set tmpDir to path to temporary items with folder creation

→ alias “…”

set f to "_someVarName.txt"

→ “_someVarName.txt” (text)

tmpDir & f

→ creates a list (an alias and a text string)

set __hfs_out to (tmpDir & f) as Unicode text

→ coerces the list {alias, text} to text by coercing the alias explicitly to text

I got the message, loud & clear.

Thank you Stefan