
Trouble understanding IGOR open command, s_filename, and returning strings

patarroyo
Here is some code I've written to do that:
Function ShortenFileName(long_filename) //This function takes a long_filename and shortens it to the yyyymmdd_## format //that is used for TNMR files //long_filename is obtained as part of the NMR STRUCT String long_filename //short_filename is the new name, keeps wave names a manageable legnth //FileID is essentially the format of short_filename, and a traditional way of keeping track of experiments String short_filename, FileID="([[:digit:]]+_[[:digit:]]+)" //Looks for just that format in long_filename, dumps it into short_filename SplitString/E=(FileID) long_filename, short_filename //print for troubleshooting print short_filename // return short_filename End
Problem: I've commented out the return statement because that is not working. Essentially, I'd like to replace "long_filename" with "short_filename". If I uncomment the return statement, I get an error. I am confused, because short_filename has been previously declared, so I don't get what I am doing wrong.
Problem: I don't understand where S_fileName comes from. It is obviously not in this function, but on IV-136 of the IGOR manual, some example code (see below) is given that uses S_fileName without intializing it. Is this a string that gets auto-generated whenver Open is invoked? I'm having a hard time finding documentation.
Function/S DoOpenFileDialog() Variable refNum String message = "Select a file" String outputPath String fileFilters = "Data Files (*.txt,*.dat,*.csv):.txt,.dat,.csv;" fileFilters += "All Files:.*;" Open /D /R /F=fileFilters /M=message refNum outputPath = S_fileName return outputPath // Will be empty if user canceled End
Function/S ...
to declare a string return.--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
March 27, 2018 at 04:41 pm - Permalink
It is an operation output variable which is automatically declared by the Igor compiler and created by the operation. Execute this for details:
DisplayHelpTopic "Local Variables Used By Igor Operations"
See also the "Output Variables" section of the help for Open.
March 27, 2018 at 05:33 pm - Permalink