Hey guys, I got a program that it ends up a little bit to big, so I'm trying in many ways to make it smaller, and now I'm trying to learn how to use scripts, for exemple, I have this: nt = 112 ; Time 1 (mys) nt2 = 81 ; Time 2 (mys) T=(dindgen(nt)*0.1+1.); Mys T2=(dindgen(nt2)+20);Mys time=[T,T2] ; vector time n=300000 R=6.*randomu(Seed,n, /Normal) + 8. K= where(R gt 0.5 and R lt 18.5, count) Np = count P=fltarr(nt+nt2,Np) P[0,*]=R[K] Here is my period distribution, as I was wondering if I could put this as a script, just like @Period And Period.pro would be: nt = 112 nt2 = 81 n=300000 R=6.*randomu(Seed,n, /Normal) + 8. K= where(R gt 0.5 and R lt 18.5, count) Np = count P=fltarr(nt+nt2,Np) P[0,*]=R[K] Would that return all the variables to the program or I need to call them? At this one, I need to return P and Np, is there somehow I do it? Thanks guys!

0 |

12/2/2016 8:26:06 PM

On 12/02/2016 09:26 PM, Edson Filho wrote: > Hey guys, I got a program that it ends up a little bit to big, so > I'm trying in many ways to make it smaller, and now I'm trying to learn how > to use scripts, for exemple, I have this: > > nt = 112 ; Time 1 (mys) > nt2 = 81 ; Time 2 (mys) > T=(dindgen(nt)*0.1+1.); Mys > T2=(dindgen(nt2)+20);Mys > time=[T,T2] ; vector time > > n=300000 > R=6.*randomu(Seed,n, /Normal) + 8. > > K= where(R gt 0.5 and R lt 18.5, count) > Np = count > > P=fltarr(nt+nt2,Np) > P[0,*]=R[K] > > Here is my period distribution, as I was wondering if I could put this as a script, just like > > @Period > > And Period.pro would be: > nt = 112 > nt2 = 81 > n=300000 > R=6.*randomu(Seed,n, /Normal) + 8. > > K= where(R gt 0.5 and R lt 18.5, count) > Np = count > > P=fltarr(nt+nt2,Np) > P[0,*]=R[K] > > Would that return all the variables to the program or I need to call them? > At this one, I need to return P and Np, is there somehow I do it? if you use a script, it behaves as if you had cut-and-past it to the command line. So, no need to to return anything. for more details see e.g. http://homepages.see.leeds.ac.uk/~lecjm/Teaching/IDL_course/Notes/notes/node25.html Using scripts is rarely a good idea, but i hope my comment & link help anyway, Markus

0 |

12/5/2016 10:38:49 AM