
symbolic paths and opening files

kbrowne
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
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:
See http://www.igorexchange.com/node/908 for an example.
And this for more examples.
November 5, 2014 at 10:18 pm - Permalink
Kevin
November 6, 2014 at 01:58 pm - Permalink