Load wave details from IBW files directly from binary (without loading the data)
The following functions load the wave name, wave note or wave dimensions directly from the binary data of a given .ibw file without loading the file itself into Igor. The code should work for all file versions, but was not tested exhaustively and does not contain any error handling. Let me know if you find a file that does not work.
function/S readIBWname(string path) // reads wave name from .ibw file
int fileID, version
Open/Z/R fileID as path
if (V_flag != 0)
return ""
endif
FBinRead/B=3/F=2/U fileID, version
int length = 20 + 12*(version>3)
int offset = 6 + 8*(version==1) + 16*(version==2) + 20*(version==3) + (64 + 22)*(version>3)
if (version > 5)
FSetPos fileID, 56
FBinRead/B=3/F=2/U fileID, length
FStatus fileID
offset = V_logEOF-length
endif
string name = PadString("", length, char2num(" "))
FSetPos fileID, offset
FBinRead fileID, name
Close fileID
return UnpadString(name,0)
end
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function/S readIBWnotes(string path) // reads wave notes from .ibw file
int fileID, version, chckSum = 0, wSize = 0, nSize = 0, fSize = 0
Open/Z/R fileID as path
if (V_flag != 0)
return ""
endif
FBinRead/B=3/F=2/U fileID, version
if (version < 2)
return ""
endif
if (version > 3)
FBinRead/B=3/F=2/U fileID, chckSum // chckSum is only read to move position forward
endif
FBinRead/B=3/F=3/U fileID, wSize
if (version > 3)
FBinRead/B=3/F=3/U fileID, fSize
endif
FBinRead/B=3/F=3/U fileID, nSize
if (version <= 3)
FBinRead/B=3/F=3/U fileID, fSize
endif
int offset = wSize + fSize + 8*(version==1) + 16*(version==2) + 20*(version==3) + 64*(version>3)
string notes = PadString("", nSize, char2num(" "))
FSetPos fileID, offset
FBinRead fileID, notes
Close fileID
return notes
end
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function/Wave readIBWdimensions(string path) // reads total no. of points and dimension size (if available) from .ibw file into free wave
int fileID, version, points
Open/Z/R fileID as path
if (V_flag != 0)
return $""
endif
FBinRead/B=3/F=2/U fileID, version
int offset = version > 3 ? 12 + 64 : 42 + 8*(version==1) + 16*(version==2) + 20*(version==3)
Make/D/Free/N=(version > 3 ? 5 : 1) output // output is: [total points, p, q, r, s] or just [total points] for files with version < 5.
FSetPos fileID, offset
FBinRead/B=3/F=3/U fileID, points
output[0] = points
if (version > 3)
offset = 68 + 64
Make/D/Free/N=(4) dims
FSetPos fileID, offset
FBinRead/B=3/F=3/U fileID, dims
output[1,4] = dims[p-1]
endif
Close fileID
return output
end
Forum
Support
Gallery
Igor Pro 10
Learn More
Igor XOP Toolkit
Learn More
Igor NIDAQ Tools MX
Learn More