RE: Strange use of FrontEnd`FileName
- To: mathgroup at smc.vnet.net
- Subject: [mg71721] RE: [mg71664] Strange use of FrontEnd`FileName
- From: "Philipp" <philipp.m.o at gmail.com>
- Date: Mon, 27 Nov 2006 04:04:57 -0500 (EST)
Dear Li, I never questioned that the FrontEnd`FileName wrapper (Head) worked in the original statement, i.e., ToFileName accepted input wrapped in FrontEnd`FileName. My question was, why it was necessary to wrap the result of Extract in the FrontEnd`FileName Head, and why ToFileName accepted input with FrontEnd`FileName. Even the error message caused by your In[16], where you wrap the directory list in test, states that "ToFileName::strse: String or list of strings expected at position 1 ...". Following your logic In[1]:= fn = "FileName" /. NotebookInformation[EvaluationNotebook[]] Out[1]= FrontEnd`FileName[{$RootDirectory, E:, Common, Desktop}, Untitled-1.nb, CharacterEncoding -> WindowsANSI] In[2]:= ex0 = Extract[fn, {1}] ex1 = Extract[fn, {1}, FrontEnd`FileName] Out[2]= {, E:, Common, Desktop} FrontEnd`FileName[{$RootDirectory, E:, Common, Desktop}] In[4]:= ToFileName[ex0] ToFileName[ex1] Out[4]= E:\Common\Desktop\ E:\Common\Desktop\ The last two statements still give the same answer, although ex1 has FrontEnd`FileName wrapper, In[6]:= Head[ex0] Head[ex1] Out[6]= List FrontEnd`FileName Cheers, Philipp. -----Original Message----- From: À÷Õý¼ª [mailto:zhengji.li at gmail.com] Sent: Monday, November 27, 2006 9:16 AM To: Philipp Cc: mathgroup at smc.vnet.net Subject: [mg71721] Re: [mg71664] Strange use of FrontEnd`FileName Philipp, Firstly, see what's happened with the use of extract. In[8]:= "FileName" /. NotebookInformation[EvaluationNotebook[]] Out[8]= FrontEnd`FileName[{$RootDirectory, "C:", Documents and Settings", ..., "Desktop"}, Untitled-2.nb, CharacterEncoding -> WindowsANSI] In[9]:= Extract["FileName" /. NotebookInformation[ EvaluationNotebook[]], {1}, FrontEnd`FileName] Out[9]= FrontEnd`FileName[{$RootDirectory, "C:", Documents and Settings", ..., "Desktop"}] Secondly, ToFileName really works with FrontEnd`FileName[{$RootDirectory, "C:", Documents and Settings", ..., "Desktop"}]. Let's check it out: In[16]:= FrontEnd`FileName[{$RootDirectory, "C:", "Desktop"}] // ToFileName (* This is OK*) Remove[test]; test[{$RootDirectory, "C:", "Desktop"}] // ToFileName (* This is bad *) {$RootDirectory, "C:", "Desktop"} // ToFileName (* OK, too *) Out[16]= C:\Desktop\