" delincr, macro by Nader Amadeu, FU Berlin, 2007 " " Copyright (c) 2006 Nader de Sousa Amadeu " " Permission is hereby granted, free of charge, to any person obtaining a copy " " of this software and associated documentation files (the ``Software''), " " to deal in the Software without restriction, including without limitation " " the rights to use, copy, modify, merge, publish, distribute, sublicense, " " and/or sell copies of the Software, and to permit persons to whom the " " Software is furnished to do so, subject to the following conditions: " " The above copyright notice and this permission notice shall be included in " " all copies or substantial portions of the Software. " " THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR " " IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, " " FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE " " AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER " " LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING " " FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER " " DEALINGS IN THE SOFTWARE. " "------------------- README ------------------------" " delincr, version from nov 2007." " This is a MAGICAL II macro to delete one increment from an array of FIDs." " Place it in the $HOME/vnmrsys/maclib directory and type delincr. " " at your Vnmr(TM) prompt. Optionally type delincr(7), to delete the " " increment number 7. The new array will be saved to experiment" " library 5 (Exp5). You will be asked for overwriting-confirmation." " It only works for experiments with only one array variable." " It cannot yet work with non-numeric variables." " USAGE: delincr" " More Info: See Varian NMR News Volume 15, Issue 42 from 2006-10-31" "----------------- Is there exp5? Am I in exp5? -------------------" exists(userdir+'/exp5','file'):$e if $e<0.5 then cexp(5) else jexp:$currexp_nr if ($currexp_nr = 5) then write('error','Move to another workspace and try again. Example: jexp4 mf(5,4) delincr') abort endif input('The contents of exp5 will be lost. Do you want to continue? '):$response if ($response <> 'y') then write('error','Aborting! Exp5 was not changed.') abort endif endif "------------- ENTER TARGET INCREMENT AND TEST IT -----------------" if ($#>0) then $vorn=$1 else input('Enter one increment to be deleted OR v to view array first: '):$vorn endif if typeof('$vorn')=1 then if ($vorn= 'v') then input('Enter display command (Ex: wft dssh dssl OR for nothing): '):$cmd {$cmd} flip('graphics','on') input('Enter one increment to be deleted: '):$target else write('error','I cannot understand you. Sorry!') abort endif else $target=$vorn endif if (arraydim <= 1 OR $target > arraydim) then write('error','Index out of bounds. Check values first!') abort endif "------------- START TRANSFERING DATA -----------------" clradd $incr_nr = 1 REPEAT if ($incr_nr <> $target) then df($incr_nr) add('new') endif $incr_nr = $incr_nr +1 UNTIL $incr_nr > arraydim shell('(cp '+curexp+'/text '+userdir+'/exp5/text )') shell('echo One increment was deleted >> '+userdir+'/exp5/text ') jexp5 $narray=' ' shell('(echo '+array+' |awk -F, \'{print NF}\' )'):$narray if ($narray <> '1') then write('error','Sorry! I can only work with more than one array variable yet!') abort endif $arrayvar=array $ct=ct $fn=fn $oldarraysize = size($arrayvar) $oldarray={array} {array}=1 $oldarrayidx=1 $newarrayidx=1 if ($target = 1) then $oldarrayidx=2 endif REPEAT {$arrayvar}[$newarrayidx]=$oldarray[$oldarrayidx] $newarrayidx = $newarrayidx + 1 $oldarrayidx = $oldarrayidx + 1 if ($oldarrayidx = $target) then $oldarrayidx = $oldarrayidx + 1 endif UNTIL ($oldarrayidx > $oldarraysize ) calcdim setvalue('ct',$ct) setvalue('fn',$fn) groupcopy('current','processed','acquisition') exists('$cmd','parameter'):$e if $e=1 then {$cmd} else wft dssh dssl endif write('error','Your are now in Exp5 and one increment was deleted. Former data in Exp%d!',$currexp_nr) flip('graphics')