#pragma rtGlobals=1 // Use modern global access method. #pragma Version=2.20 #pragma IgorVersion=6.1 ////////////// //for writing out data (q-i-s-dum-dum-dum) from the "type" folder //if fullpath is a complete HD path:filename, no dialog will be presented //if fullpath is just a filename, the save dialog will be presented (forced if dialog =1) //lo,hi are an (optional) range of the data[lo,hi] to save (in points) //if lo=hi=0, all of the data is written out // //////// 27 OCT 04 // now writes 6-column data such that the last three columns are the divergence // = a constant value, set in Init_MainUSANS() // Function WriteUSANSWaves(type,fullpath,lo,hi,dialog) String type,fullpath Variable lo,hi,dialog //=1 will present dialog for name SVAR USANSFolder = root:Packages:NIST:USANS:Globals:gUSANSFolder String termStr="\r\n" //VAX uses only as terminator, but only CRLF seems to FTP correctly to VAX String destStr="",formatStr = "%15.6g %15.6g %15.6g %15.6g %15.6g %15.6g"+termStr destStr = USANSFolder+":"+type Variable refNum,integer,realval //*****these waves MUST EXIST, or IGOR Pro will crash, with a type 2 error**** WAVE qvals =$(destStr + ":Qvals") WAVE inten=$(destStr + ":DetCts") WAVE sig=$(destStr + ":ErrDetCts") //check each wave If(!(WaveExists(qvals))) Abort "qvals DNExist in WriteUSANSWaves()" Endif If(!(WaveExists(inten))) Abort "inten DNExist in WriteUSANSWaves()" Endif If(!(WaveExists(sig))) Abort "sig DNExist in WriteUSANSWaves()" Endif // 27 OCT 04 SRK // make a dummy wave to hold the divergence, and write it as the last 3 columns // and make the value negative as a flag for the analysis software // Duplicate/O qvals,dumWave NVAR DQv=$(USANSFolder+":Globals:MainPanel:gDQv") dumWave = - DQv /// if(dialog) PathInfo/S savePathName fullPath = DoSaveFileDialog("Save data as") If(cmpstr(fullPath,"")==0) //user cancel, don't write out a file Close/A Abort "no data file was written" Endif //Print "dialog fullpath = ",fullpath Endif //write out partial set? Duplicate/O qvals,tq,ti,te ti=inten te=sig if( (lo!=hi) && (lo as terminator, but only CRLF seems to FTP correctly to VAX String formatStr = "%15.6g %15.6g %15.6g %15.6g %15.6g %15.6g"+termStr String newFName="",suffix="_6col.cor",fullpath="" Variable refNum_old,refnum_new,integer,realval // 08 NOV 04 SRK Variable ii,dQv = -0.037 //hard-wired value for divergence (pre- NOV 2004 value) /// Open/R/D/M="Select the 3-column data file"/T="????" refnum_old //won't actually open the file If(cmpstr(S_filename,"")==0) //user cancel, don't write out a file Close/A Abort "no data file was written" Endif fullpath = S_filename newFname = fullpath[0,strlen(fullpath)-5]+suffix Print fullpath Print newFname String tmpStr String extraStr="" sprintf extraStr,"%15.6g %15.6g %15.6g",dQv,dQv,dQv extraStr += termStr //actually open each of the files Open/R refNum_old as fullpath Open refNum_new as newFname //7 header lines for(ii=0;ii<7;ii+=1) FReadLine refNum_old, tmpStr //returns only CR fprintf refnum_new,tmpStr+"\n" // add LF so file has CRLF endfor do FReadLine refNum_old, tmpStr if(strlen(tmpStr)==0) break endif fprintf refnum_new,tmpStr[0,strlen(tmpStr)-2]+extraStr while(1) Close refnum_old Close refnum_new Return(0) End