mark
                
                    I was wondering how the "file_name_for_best_solutions" command works, I'd like to export some parameters everytime a new best solution is found during a refinement but I can't find a way to do it.
Also I'd like to do similar thing but only when rwp is below a critical value which I decide. Is it possble?
I tried with this piece of code but seems it doesn't work.
Thanks
#define write_out
#ifdef write_out
	#prm rwp = Get(r_wp);
	#if rwp < 16;
		out "results.txt" append
		Out(SName, "%s\t")
		Out(Cycle, "%11.5f\t")
		Out(Get (r_wp), "\t %11.5f\t")
		Out(csl, " %11.5f\t")
		Out(a, " %11.5f\t")
		Out(c, " %11.5f\t")
		Out_String(\n)
	#endif
#endif
                
            
            
                    
                                mark
                
                    UPDATE:
I'm trying to get the rwp during refinement and i noticed that the following line return the correct rwp
prm rwp = If(Get(r_wp) < 18, Get(r_wp), 9999); : 0
113  Time   1.11  Rwp   11.976   -0.020 MC     0.00 1
114  Time   1.11  Rwp   11.959   -0.017 MC     0.00 1
115  Time   1.12  Rwp   11.946   -0.013 MC     0.00 1
The strange thing is that once I try to build up an if statement to launch a macro when rwp <18 r_wp values become huge (10e+10 and more)
prm rwp = If(Get(r_wp) < 18, Get(r_wp), 9999); : 0
if rwp <18 {
	prm test = rpw; : 0
}
110  Time   1.20  Rwp 2567624822562.117 -38869088.510 MC   121.58 1
111  Time   1.21  Rwp 2567544576352.783 -80246209.334 MC   247.20 1
112  Time   1.22  Rwp 2567435450377.961 -109125974.822 MC   598.69 2
so ... How is possible to build an if statement taking as condition "rwp <18" or similar? 
If I've understood well using preprocessor #if is not possible as Get(r_wp) is not definided at the preprocessor level.
Thanks
                
            
            
                    
                                alancoelho
                
                    The following keywords should do what you want:
out_prm_vals_per_iteration
out_prm_vals_on_convergence
out_prm_vals_filter
out_prm_vals_dependents_filter
Look them up in Technical_Reference.PDF
                
            
            
                    
                                alancoelho
                
                    To end a refinement based on Rwp then use:
iters = If(Get(r_wp) < 11, 0, 1000000);
                
            
            
                    
                                mark
                
                    Thank you Alan for the kind answear.
out_prm_vals_per_iteration etc... are extremelly useful commands!
Unfortunally I've noticed that by using If(); construct is not possible to call other macros containing complex instructions.
What I'd like to do is to export Ycalc, Yobs, Ydiff and HKL  everytime a new best solution is found as well as everytime refinement is converged or r_wp is below certain values.
I was thinking of using Get(r_wp) command and build some if-else conditions.
Can you give me some advices?
Thanks a lot
Best