After prompting the user to select a text file, the file is opened and a variable is created based on the site name contained in this text data filename as follows
dt.rawdata = Open (
Pick File( ......
// Create string that is filename
dtname = dt.rawdata << Get Name;
// Create variable called siteid that removes just the site name from the filename
If( Word( 1, dtname, "_" ) == "UC",
siteid = "UC_" || Word( 2, dtname, "_" ),
siteid = Word( 1, dtname, "_" )
What I'm struggling with now is how to open a JMP data file whose name contains the siteid just determined. There are about 40 .xls and .jmp data files in a directory and I'm trying to open the only JMP file that contains siteid in the filename as follows
where ? is a wildcard for the text string that follows LTEM Data. The filenames follow the format siteid LTEM Data, yyyy - YTD.jmp where yyyy refers to starting year and varies depending on the site id.
That works great. I was wondering how with the code provided it managed to grab the correct JMP files even though many other files with the siteid prefix existed. Turns out it was luck that the correct file I want to open was the first listed with the siteid prefix. So, to ensure that I opened the JMP file in the event that the first file corresponding to siteid in the list wasn't a JMP file, I added the following Ends With code.