DefaultFont "Helvetica" printf "\r%s %s restarting this file\r\r",date(),time() #pragma rtGlobals= 2 Menu "Macros" "Find a Wave", FindaWave_("") End Proc Layout_Corner_Labels_Style_() Add_Corner_Labels_To_Layout() End Proc Add_Corner_Labels_To_Layout() : LayoutStyle PauseUpdate; Silent 1 // modifying window... Textbox/C/N=stamp0/F=0/A=RB/X=0.1/Y=0.1 "\\Z06\\{\"%s %s\",date(), time()}" Textbox/C/N=stamp1/F=0/A=LB/X=0.1/Y=0.1 "\\Z06\\{\"%s\",CornerStamp1_()}"+":"+WinName(0, 1) EndMacro Function/S CornerStamp1_() PathInfo home // creates String s_path return S_path+IgorInfo(1) End Function NextInRange(range,last) // given a string like "2-5,7,9-12,50" get the next number in this compound range // the range is assumed to be monotonic, it returns NaN if no more values String range // list defining the range Variable last // last number obtained from this range, use -Inf to get start of range, it returns the next // find first item in the list that should use next String item Variable m,i,j Variable first // first value in an item do item = StringFromList(j,range,",") first = str2num(item) // do we need to check for NaN in first? if (numtype(first)) return NaN elseif (last=first, check to see if item is a '2-5' type range m=-1 // remove any leading white space from item do m += 1 while (char2num(item[m])<=32) item = item[m,strlen(item)-1] i = strsearch(item,"-",1) // location of first '-' after the first character if (i<0) // only a single number, not a dash type range, keep looking j += 1 continue endif // check to see if last was in the range of item, but not the last value if (last>=str2num(item) && last0) return NaN End //Function TestNextInRange(range) // String range // range = SelectString(strlen(range) ,"-16,-7--3,-1-2,5,50-54,99",range) // Variable i = -Inf // printf "for range = {%s}, ", range // do // i = NextInRange(range,i) // if (numtype(i)) // break // endif // printf "%d ", i // while (!numtype(i)) // print "" //End Function ItemsInRange(range) // given a string like "2-5,7,9-12,50" get the total number of values in the range String range // list defining the range // the range is assumed to be monotonic, it returns NaN on error String item // each of the comma sepated items Variable len=0 // the result, number of values represented Variable m,i,j,N=ItemsInList(range,",") for (j=0;j0) i2 = str2num(str[i+1,inf]) i = i1 do out += num2str(i)+sep i += 1 while (i<=i2) else out += num2str(i1)+sep endif j += 1 while (j '%s'\r",range, compressRange(range,";") // range = "1;2;3;4;5;9;10;11" // printf "'%s' ---> '%s'\r",range, compressRange(range,";") // range = "4" // printf "'%s' ---> '%s'\r",range, compressRange(range,";") // range = "4;7" // printf "'%s' ---> '%s'\r",range, compressRange(range,";") // range = "-10;-9;-8;-7;-6;-5;-3;-2;-1;0;1;2;7;9;22" // printf "'%s' ---> '%s'\r",range, compressRange(range,";") //End Function FindaWave_(searchString) String searchString if (strlen(searchString)<1) searchString="*" Prompt searchString,"search string" DoPrompt "choose one", searchString endif String result Prompt result,"choose a wave",popup, WaveList(searchString, ";", "") DoPrompt "choose one", result print result EndMacro Function printWave(w) // print a wave (vector or matrix) to history Wave w if (!WaveExists(w)) DoAlert 0, "in 'printWave', wave does not exist" return 1 endif if (DimSize(w, 1)<=1) // for vectors printvec(w) elseif (DimSize(w, 2)==0) // for 2-d matrix return printmat(w) else print "cannot yet handle dimensions 3 or 4" endif return 0 End Static Function printvec(w) // print a vector to screen Wave w String name=NameOfWave(w) Wave/T tw=$GetWavesDataFolder(w,2) Wave/C cw=$GetWavesDataFolder(w,2) Variable waveIsComplex = WaveType(w) %& 0x01 Variable numeric = (WaveType(w)!=0) Variable i=0, n, maxPrint=20 n = numpnts(w) maxPrint = min(n,maxPrint) printf "%s = {", name do if (waveIsComplex) // a complex wave printf "(%g, %g)", real(cw[i]),imag(cw[i]) endif if (numeric %& (!waveIsComplex)) // a simple number wave printf "%g", w[i] endif if (!numeric) // a text wave printf "\"%s\"", tw[i] endif if (i<(n-1)) printf ", " endif i += 1 while (imaxPrint) printf "...}\ronly printed %d of %d values\r",maxPrint,n else printf "}\r" endif End Static Function printmat(m) Wave m if (DimSize(m, 1)==0 || DimSize(m,2)!=0) // for 2-d matrix only DoAlert 0, "Can only print 2-d matricies with printmat" return 1 endif String name=NameOfWave(m) Wave/C mc=$GetWavesDataFolder(m,2) if (DimSize(m, 0)==2 && DimSize(m, 1)==2) if (WaveType(m) %& 0x01) // true for complex numbers print name+"[0][0] =",mc[0][0],"; ",name+"[0][1] =",mc[0][1] print name+"[1][0] =",mc[1][0],"; ",name+"[1][1] =",mc[1][1] else print name+"[0][0] =",m[0][0],"; ",name+"[0][1] =",m[0][1] print name+"[1][0] =",m[1][0],"; ",name+"[1][1] =",m[1][1] endif elseif (DimSize(m, 0)>=3 && DimSize(m, 1)==2) if (WaveType(m) %& 0x01) // true for complex numbers print name+"[0][0] =",mc[0][0],"; ",name+"[0][1] =",mc[0][1] print name+"[1][0] =",mc[1][0],"; ",name+"[1][1] =",mc[1][1] print name+"[2][0] =",mc[2][0],"; ",name+"[2][1] =",mc[2][1] else print name+"[0][0] =",m[0][0],"; ",name+"[0][1] =",m[0][1] print name+"[1][0] =",m[1][0],"; ",name+"[1][1] =",m[1][1] print name+"[2][0] =",m[2][0],"; ",name+"[2][1] =",m[2][1] endif elseif (DimSize(m, 0)==2 && DimSize(m, 1)>=3) if (WaveType(m) %& 0x01) // true for complex numbers print name+"[0][0] =",mc[0][0],"; ",name+"[0][1] =",mc[0][1],"; ",name+"[0][2] =",mc[0][1] print name+"[1][0] =",mc[1][0],"; ",name+"[1][1] =",mc[1][1],"; ",name+"[1][2] =",mc[1][1] else print name+"[0][0] =",m[0][0],"; ",name+"[0][1] =",m[0][1],"; ",name+"[0][2] =",m[0][2] print name+"[1][0] =",m[1][0],"; ",name+"[1][1] =",m[1][1],"; ",name+"[1][2] =",m[1][2] endif else if (WaveType(m) %& 0x01) // true for complex numbers print name+"[0][0] =",mc[0][0],"; ",name+"[0][1] =",mc[0][1],"; ",name+"[0][2] =",mc[0][1] print name+"[1][0] =",mc[1][0],"; ",name+"[1][1] =",mc[1][1],"; ",name+"[1][2] =",mc[1][1] print name+"[2][0] =",mc[2][0],"; ",name+"[2][1] =",mc[2][1],"; ",name+"[2][2] =",mc[2][1] else print name+"[0][0] =",m[0][0],"; ",name+"[0][1] =",m[0][1],"; ",name+"[0][2] =",m[0][2] print name+"[1][0] =",m[1][0],"; ",name+"[1][1] =",m[1][1],"; ",name+"[1][2] =",m[1][2] print name+"[2][0] =",m[2][0],"; ",name+"[2][1] =",m[2][1],"; ",name+"[2][2] =",m[2][2] endif endif if (DimSize(m,0)>3 || DimSize(m,1)>3) printf "Only printed part of the (%d x %d) matrix\r",DimSize(m,0),DimSize(m,1) endif return 0 End Function AfterFileOpenHook(refNum,file,pathName,type,creator,kind) Variable refNum, kind String file,pathName,type,creator if ((kind==1) || (kind==2)) // an experiment (packed or unpacked) printf "\r%s %s restarting this file from '%s:%s'\r\r",date(),time(),pathName,file endif End Function IgorStartOrNewHook(IgorApplicationNameStr) String IgorApplicationNameStr PathInfo Igor // put path value into (local) S_Path printf "%s %s starting this file from '%s'\r\r",date(),time(),S_Path GetWindow kwCmdHist wsize V_right = (V_right>900) ? V_right-100 : V_right MoveWindow /C V_left+20,V_top-40,V_right,V_bottom-2 End