-- Xmover written by Giuseppe 01.16.2008 -- program that manipulates spectral bands under iNMR -- perform simple spectral editing between 2 regions of the same spectrum -- 3 options are available to the user: addition, substitution, swap -- with the console option "for all documents" -- the data points are taken from the frontmost document only -- while the operation is performed on all spectra local source = ask "peak to move ? (ppm)" -- asks the user for input; all the variables are declared locally print( "source at "..source.." ppm") -- visual feedback -- now we ask the user for the width of the regions local span = ask "how wide is the region to move ? (ppm)" print( "the region is "..span.." ppm wide") -- this value is common for both source and destination local half = span / 2 local dest = ask "destination ? (ppm)" print( "destination at "..source.." ppm") -- now we have all the parameters region( source + half, source - half, 1e6, -1e6, 1e6, -1e6 ) -- selects the source, in 3D local Spoints = copy() -- copies the source local n = Spoints.x * Spoints.y * Spoints.z -- number of source points region( dest + half, dest - half, 1e6, -1e6, 1e6, -1e6 ) -- selects the destinaton, in 3D local Dpoints = copy() -- copies the destination local m = Dpoints.x * Dpoints.y * Dpoints.z -- number of source points if (m < n) then -- if one of the frequencies is outside the spectral width n = m -- the two regions are not of the same size end local choice = ask "Add, Paste or Swap ? (A / P / S)" choice = string.sub( choice, 1, 1 ) -- extracts the first character choice = string.upper( choice ) -- converts into uppercase if choice == "A" then for i = 1,n do Dpoints[i] = Dpoints[i] + Spoints[i] -- point by point addition end paste( Dpoints ) -- back into the spectrum print ("added "..source.." to "..dest) -- confirmation message elseif choice == "P" then -- user chose "Paste" paste( Spoints ) print ("pasted "..source.." onto "..dest) elseif choice == "S" then -- user chose "Swap" paste( Spoints ) region( source - half, source + half ) paste( Dpoints ) print ("swapped "..source.." with "..dest) else print ("the end") end -- not a valid choice (user aborted) amp() -- updates the screen