source: sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v4.00/WriteModelData_v40.ipf @ 304

Last change on this file since 304 was 304, checked in by srkline, 15 years ago

WIN OS-level default of .txt extension for saved files has been removed. Requested file name is now properly used.

Correct logic for turning off file checking if there is an alias in the UserProcedures? folder.

File size: 2.1 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2#pragma IgorVersion = 6.0
3
4Proc WriteModelData(xwave,ywave,delim,term)
5        String xwave,ywave,delim,term
6        Prompt xwave,"X data",popup,PossibleModelWaves("x*")
7        Prompt ywave,"Y data",popup,PossibleModelWaves("y*")
8        Prompt delim,"delimeter",popup,"tab;space;"
9        Prompt term,"line termination",popup,"CR;LF;CRLF;"
10       
11        //Print xwave, ywave, delim, term
12       
13        fWriteModelData($xwave,$ywave,delim,term)
14       
15End
16
17Function/S PossibleModelWaves(filterStr)
18        String filterStr
19       
20        String list,tmplist,DF,newList=""
21        Variable ii,num
22       
23        //waves in root
24        list = WaveList(filterStr,";","")
25       
26        //add possble smeared models that are housed in data folders
27        ControlInfo/W=WrapperPanel popup_0
28        if(V_flag==0 || cmpstr(S_Value,"No data loaded")==0)
29                return(list)
30        else
31                DF="root:"+S_Value
32                SetDataFolder $DF
33                if(cmpstr(filterStr,"x*")==0)
34                        tmplist = WaveList("*_q",";","")
35                        tmpList += WaveList("GFitX_*",";","")
36                else
37                        tmplist = WaveList("smea*",";","")
38                        tmpList += WaveList("GFit_*",";","")
39                endif
40                //prepend these list items with the folder
41                num=itemsinlist(tmplist)
42                if(num > 0)
43                        ii=0
44                        do
45                                newList += DF+":"+StringFromList(ii, tmpList, ";") + ";"
46                                ii+=1
47                        while(ii<num)
48                       
49                        //then add to the list
50                        list += newList
51                endif
52        endif
53       
54        SetDataFolder root:
55        return(list)
56end
57
58Function fWriteModelData(xwave,ywave,delim,term)
59        Wave xwave,ywave
60        String delim,term
61       
62        String formatStr="",fullpath=""
63        Variable refnum
64        //setup delimeter and terminator choices
65        If(cmpstr(delim,"tab")==0)
66                //tab-delimeted
67                formatStr="%15.4g\t%15.4g"
68        else
69                //use 3 spaces
70                formatStr="%15.4g   %15.4g"
71        Endif
72        If(cmpstr(term,"CR")==0)
73                formatStr += "\r"
74        Endif
75        If(cmpstr(term,"LF")==0)
76                formatStr += "\n"
77        Endif
78        If(cmpstr(term,"CRLF")==0)
79                formatStr += "\r\n"
80        Endif
81       
82        Open/D/T="????" refnum as NameofWave(ywave)+".txt"      //doesn't open file
83        If(cmpstr(S_filename,"")==0)
84                //user cancel, don't write out a file
85                Close/A
86                Abort "no data file was written"
87        Endif
88        fullpath=S_filename
89        Open refnum as fullpath
90       
91        fprintf refnum,"Model data created %s\r\n",(date()+" "+time())
92        wfprintf refnum,formatStr,xwave,ywave
93        Close refnum
94        return(0)
95End
Note: See TracBrowser for help on using the repository browser.