source: sans/Analysis/branches/ajj_23APR07/IGOR_Package_Files/Put in User Procedures/SANS_Models_v3.00/WriteModelData.ipf @ 170

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

Fixed the routine that writes model data XY for export to be data-folder aware so that it can write out smeared models which are housed in data folders.

File size: 2.0 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                else
36                        tmplist = WaveList("smea*",";","")
37                endif
38                //prepend these list items with the folder
39                num=itemsinlist(tmplist)
40                ii=0
41                do
42                        newList += DF+":"+StringFromList(ii, tmpList, ";") + ";"
43                        ii+=1
44                while(ii<num)
45               
46                //then add to the list
47                list += newList
48        endif
49       
50        SetDataFolder root:
51        return(list)
52end
53
54Function fWriteModelData(xwave,ywave,delim,term)
55        Wave xwave,ywave
56        String delim,term
57       
58        String formatStr="",fullpath=""
59        Variable refnum
60        //setup delimeter and terminator choices
61        If(cmpstr(delim,"tab")==0)
62                //tab-delimeted
63                formatStr="%15.4g\t%15.4g"
64        else
65                //use 3 spaces
66                formatStr="%15.4g   %15.4g"
67        Endif
68        If(cmpstr(term,"CR")==0)
69                formatStr += "\r"
70        Endif
71        If(cmpstr(term,"LF")==0)
72                formatStr += "\n"
73        Endif
74        If(cmpstr(term,"CRLF")==0)
75                formatStr += "\r\n"
76        Endif
77       
78        Open/D refnum as NameofWave(ywave)+".txt"       //doesn't open file
79        If(cmpstr(S_filename,"")==0)
80                //user cancel, don't write out a file
81                Close/A
82                Abort "no data file was written"
83        Endif
84        fullpath=S_filename
85        Open refnum as fullpath
86       
87        fprintf refnum,"Model data created %s\r\n",(date()+" "+time())
88        wfprintf refnum,formatStr,xwave,ywave
89        Close refnum
90        return(0)
91End
Note: See TracBrowser for help on using the repository browser.