- Timestamp:
- Jul 6, 2010 5:17:53 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/ANSTO_Utils.ipf
r707 r715 174 174 175 175 return(deadtime) 176 End 177 178 179 //given a filename of a SANS data filename of the form 180 //QKKNNNNNNN.nx.hdf 181 //returns the prefix 182 Function/S GetPrefixStrFromFile(item) 183 String item 184 String invalid = "" //"" is not a valid run prefix, since it's text 185 Variable num=-1 186 187 //find the "dot" 188 String runStr="" 189 190 Variable pos = strsearch(item,".",0) 191 if(pos == -1) 192 //"dot" not found 193 return (invalid) 194 else 195 //found, skip the three characters preceeding it 196 if (pos <=7) 197 //not enough characters 198 return (invalid) 199 else 200 runStr = item[0,pos-8] 201 return (runStr) 202 Endif 203 Endif 204 End 205 206 Function/S RunDigitString(num) 207 Variable num 208 209 String numStr="" 210 211 //make 7 digit string from run number 212 sprintf numStr,"%07u",num 213 214 //Print "numstr = ",numstr 215 return(numstr) 176 216 End 177 217 … … 207 247 //if valid, return it 208 248 if (num == NaN) 209 // 3characters were not a number249 //7 characters were not a number 210 250 return (invalid) 211 251 else … … 474 514 String retStr="" 475 515 476 //your code here 477 //Assuming no issues with partialNames.... 478 479 return(partialName) 480 516 //try name with no changes - to allow for ABS files that have spaces in the names 12APR04 517 retStr = ValidFileString(partialName) 518 if(cmpstr(retStr,"") !=0) 519 //non-null return 520 return(retStr) 521 Endif 522 523 //if the partial name is derived from the file header, there can be spaces at the beginning 524 //or in the middle of the filename - depending on the prefix and initials used 525 // 526 //remove any leading spaces from the name before starting 527 partialName = RemoveAllSpaces(partialName) 528 529 //try name with no spaces 530 retStr = ValidFileString(partialName) 531 if(cmpstr(retStr,"") !=0) 532 //non-null return 533 return(retStr) 534 Endif 535 536 //try all UPPERCASE 537 partialName = UpperStr(partialName) 538 retStr = ValidFileString(partialName) 539 if(cmpstr(retStr,"") !=0) 540 //non-null return 541 return(retStr) 542 Endif 543 544 //try all lowercase (ret null if failure) 545 partialName = LowerStr(partialName) 546 retStr = ValidFileString(partialName) 547 if(cmpstr(retStr,"") !=0) 548 //non-null return 549 return(retStr) 550 else 551 return(retStr) 552 Endif 553 554 End 555 556 // Function checks for the existence of a file 557 // partialName;vers (to account for VAX filenaming conventions) 558 // The partial name is tried first with no version number 559 // 560 // *** the PATH is hard-wired to catPathName (which is assumed to exist) 561 // version numers up to ;10 are tried 562 // only the "name;vers" is returned if successful. The path is not prepended 563 // 564 // local function 565 // 566 Function/S ValidFileString(partialName) 567 String partialName 568 569 String tempName = "",msg="" 570 Variable ii,refnum 571 572 ii=0 573 do 574 if(ii==0) 575 //first pass, try the partialName 576 tempName = partialName 577 Open/Z/R/T="????TEXT"/P=catPathName refnum tempName //Does open file (/Z flag) 578 if(V_flag == 0) 579 //file exists 580 Close refnum //YES needed, 581 break 582 endif 583 else 584 tempName = partialName + ";" + num2str(ii) 585 Open/Z/R/T="????TEXT"/P=catPathName refnum tempName 586 if(V_flag == 0) 587 //file exists 588 Close refnum 589 break 590 endif 591 Endif 592 ii+=1 593 //print "ii=",ii 594 while(ii<11) 595 //go get the selected bits of information, using tempName, which exists 596 if(ii>=11) 597 //msg = partialName + " not found. is version number > 11?" 598 //DoAlert 0, msg 599 //PathInfo catPathName 600 //Print S_Path 601 Return ("") //use null string as error condition 602 Endif 603 604 Return (tempName) 481 605 End 482 606 … … 897 1021 if( !stringmatch(item,"*.SA1*") && !stringmatch(item,"*.SA2*") && !stringmatch(item,"*.SA3*") ) 898 1022 if( !stringmatch(item,".*") && !stringmatch(item,"*.pxp") && !stringmatch(item,"*.DIV")) //eliminate mac "hidden" files, pxp, and div files 899 newlist += item + ";" 1023 if (!stringmatch(item,"*.nx.hdf") && !stringmatch(item,"*.bin") && !stringmatch(item,"*.mask")) 1024 newlist += item + ";" 1025 endif 900 1026 endif 901 1027 endif
Note: See TracChangeset
for help on using the changeset viewer.