symbolic paths and opening files

I'm having a very tough time understanding when and how to open files in different ways. My goal in the following code is to open a batch of files one at a time, and 1) load the waves, and 2) pull information out of the file header. Here is what I have so far:

Function A(pathName)
    String pathName
    String fileName
    Variable index = 0
    if (strlen(pathName) == 0)
        NewPath/O temporaryPath
        pathName = "temporaryPath"
    endif
   
    fileName = IndexedFile($pathName, index, ".TXT")
    Variable result
   
    result = B(fileName, pathName)
   
End


Function B(fileName, pathName)
    String fileName
    String pathName
    LoadWave/J/D/O/A/P=$pathName fileName
   
    Variable header
    header = C(fileName, pathName)
    print header
End

Function C(fileName, pathName)
    String fileName
    String pathName
    Open/R/P= pathName as fileName
   
    String buffer
   
    FReadline fileName, buffer
    print buffer
End


However, this won't compile for me. I get "unknown/inappropriate name or symbol" in function C at FReadline fileName, buffer. Why is that? Also, I am correcting passing fileName and pathName from function B to function C? Any tips on how to correctly handle these paths from function to function would be greatly appreciated.

Another question regarding
 pathName = "temporaryPath"


I copied that from the Igor manual, but I don't understand what that's doing there. Why would we want to put the string "temporaryPath" inside a string variable?

Thanks very much for any help!!

Kevin
Quote:
I get "unknown/inappropriate name or symbol" in function C at FReadline fileName, buffer. Why is that?


FReadLine takes a file reference number as its first parameter.

Also /P takes a name as a parameter not a string. Therefore /P=pathName means "I have a symbolic path named 'pathName' that points to the folder of interest". But you have no symbolic path named pathName. Instead pathName contains the name of a symbolic path. So you need to use $ to convert the contents of the string variable pathName into a name.

For details execute:
DisplayHelpTopic "Converting a String into a Reference Using $"

Also you are not closing the file.

You should write:
Variable refNum
Open/R/P=$pathName refNum as fileName
// Use refnum ...
Close refNum


See http://www.igorexchange.com/node/908 for an example.

And this for more examples.