Changeset 664
- Timestamp:
- Apr 6, 2010 3:01:14 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/Common/NIST_XML_v40.ipf
r661 r664 65 65 SetDataFolder xmlDataSetFolder 66 66 // enforce a short enough name here to keep Igor objects < 31 chars 67 basestr = ShortFileNameString(CleanupName(getXMLDataSetTitle(xmlDataSetFolder,j),0)) 67 // Multiple data sets so we need to use titles and run numbers for naming 68 basestr = ShortFileNameString(CleanupName(getXMLDataSetTitle(xmlDataSetFolder,j,useFilename=0),0)) 68 69 baseStr = CleanupName(baseStr,0) //in case the user added odd characters 69 70 … … 196 197 197 198 //if outstr has been specified, we'll find ourselves here.... 199 //We should default to using the filename here to make life easier on people who have used the NIST reduction... 198 200 if (!cmpstr(outstr,"")) 199 basestr = CleanupName(getXMLDataSetTitle(xmlDataFolder,0),0)201 basestr = ShortFileNameString(CleanupName(getXMLDataSetTitle(xmlDataFolder,0,useFilename=1),0)) 200 202 else 201 basestr = CleanupName(outstr,0)203 basestr = ShortFileNameString(CleanupName(outstr,0)) 202 204 endif 203 205 … … 324 326 325 327 326 function/S getXMLDataSetTitle(xmlDF,dsNum )328 function/S getXMLDataSetTitle(xmlDF,dsNum,[useFilename]) 327 329 String xmlDF 328 330 Variable dsNum 331 Variable useFilename 329 332 330 333 SVAR title = root:Packages:NIST:gXMLLoader_Title 331 334 332 335 String mdstring = xmlDF+"metadata" 336 String filename 333 337 334 338 Wave/T meta = $mdstring 339 340 //Get filename to use if useFilename is specified or as a fall back if title is missing. 341 FindValue/TEXT="xmlFile"/TXOP=4/Z meta 342 filename = ParseFilePath(0,TrimWS(meta[V_Value][1]),":",1,0) 343 344 if (useFilename) 345 return filename 346 endif 347 335 348 //Check for value when there are multiple datasets 349 //Note that the use of FindValue here assumes that the tag is in column 0 so that V_Value 350 //represents the row number 351 //This will almost certainly break if your title was "Title" or "Run" 336 352 FindValue/TEXT="Title"/TXOP=4/Z meta 337 title = TrimWS(meta[V_Value][1]) 338 print meta[V_Value][1] 339 print title 353 if (V_Value >= 0) 354 //This should always be true as title is required in canSAS XML format 355 title = TrimWS(meta[V_Value][1]) 356 else 357 title = filename 358 endif 340 359 //Check for Run value 360 //If you get a run value, put it at the start of the string so it isn't lost if there is truncation 361 //One hopes that the run number will be unique... 341 362 FindValue/TEXT="Run_"+num2str(dsNum)/TXOP=4/Z meta 342 363 if (V_Value >= 0) 343 title = title+" "+TrimWS(meta[V_Value][1])344 print title364 title = TrimWS(meta[V_Value][1])+" "+title 365 //print title 345 366 else 346 367 FindValue/TEXT="Run"/TXOP=4/Z meta 347 368 if (V_Value >= 0) 348 title = title+" "+TrimWS(meta[V_Value][1])349 print title369 title = TrimWS(meta[V_Value][1])+" "+title 370 //print title 350 371 endif 351 endif352 353 if (strlen(title) > 28)354 //Prompt title, "Set New Sample Name"355 //DoPrompt "Sample Name Is Too Long", title356 do357 Execute "getXMLShorterTitle()"358 while (strlen(title) > 28)359 372 endif 360 373 … … 362 375 end 363 376 364 365 366 Proc getXMLShorterTitle()367 368 //NVAR title = root:myGlobals:gXMLLoader_Title369 370 DoWindow/K getNewTitle371 getNewTitle()372 373 PauseforUser getNewTitle374 end375 376 Window getNewTitle()377 378 PauseUpdate; Silent 1 // building window...379 NewPanel /W=(166,90,666,230) as "Sample Title Too Long!"380 SetDrawLayer UserBack381 DrawText 11,22,"The sample title is too long."382 DrawText 11,42,"Please enter a new one with a maximum length 28 characters"383 DrawText 11,72,"Current Sample Title:"384 GroupBox group0 pos={8,55},size={484,50}385 TitleBox tb_CurrentTitle,pos={150,57}, variable=root:Packages:NIST:gXMLLoader_Title,fSize=12,frame=0386 SetVariable sv_NewTitle,pos={11,77},size={476,18},title="New Sample Title"387 SetVariable sv_NewTitle,fSize=12,value=root:Packages:NIST:gXMLLoader_Title388 Button btn_SetNewTitle title="Set New Title",pos={150,110},size={200,20}389 Button btn_SetNewTitle proc=SetNewTitleButtonProc390 391 EndMacro392 393 394 Proc SetNewTitleButtonProc(ctrlName) : ButtonControl395 String ctrlName396 397 DoWindow/K getNewTitle398 399 End400 377 401 378 //AJJ 12/5/08
Note: See TracChangeset
for help on using the changeset viewer.