-- importing data from the DOSY toolbox function LineOf( name ) local len = string.len( name ) local line, parameter repeat line = io.read("*line") if line == nil then print( name.." not found" ) return end parameter = string.sub( line, 2, len+1 ) until parameter == name return line end function StringAfter( name ) local s = LineOf(name) if s == nil then return end local parenthesis = string.find( s, "%)" ) s = string.sub( s, parenthesis + 1 ) local initial = string.find( s, "%w" ) return string.sub( s, initial ) end function ValueOf( name ) local s = StringAfter(name) if s == nil then return end return tonumber( s ) end function ExtractString( name ) local s = StringAfter( name ) local delimiter = string.find( s, "\"" ) return string.sub( s, 1, delimiter - 1 ) end -- The program starts here ! local path = choosefile() if path == nil then return end io.input( path ) local X = {} local Y = {} Y.size = ValueOf "Number Of Rows" X.size = ValueOf "Points Per Row" local ArrayName = ExtractString "Y Axis Definition" print ("Y Axis Definition = ".. ArrayName) X.start = ValueOf "Lowest Frequency" X.MHz = ValueOf "Observe Frequency" local s = StringAfter "Observe Nucleus" local p = string.find( s, "-" ) X.mass = tonumber( string.sub( s, 1, p-1 ) ) X.atom = string.sub( s, p+1 ) X.width = ValueOf "Spectral Width" s = LineOf( ArrayName ) local maxY = io.read( "*number" ) for i = 3,Y.size do io.read( "*number" ) end local minY = io.read( "*number" ) if minY > maxY then minY, maxY = maxY, minY end local step = (maxY - minY) / (Y.size - 1) Y.width = step * Y.size Y.start = minY - step / 2 Y.mass = 0 Y.atom = "." Y.MHz = 1 resize( X, Y ) print( LineOf( "Data Points" ) ) local Data = {} Data.x = X.size Data.y = Y.size Data.z = 1; q = Data.x * Data.y * Data.z for i = 1,q do Data[i] = io.read( "*number" ) end print ( q, "data points read" ) region( 9999, -9999, 9999, -9999 ) paste( Data ) full( ) adj( ) bidi 'C' local last = 1 while true do local slash = string.find( path, "/", last + 1 ) if not slash then break end last = slash end path = string.sub( path, 1, last ) .."from_DosyTb" cw( ) -- standard workflow os.execute("rm -rf \""..path.."\"") export( path ) reload( ) open( path ) print "DTb_2_iNMR succesfully completed\n"