;+
; NAME:
;       MKUWORDS
;
; PURPOSE:
;      
;       MKUWORDS is a collection of functions to make unsigned 16, 24
;       and 32 bit words (both little and big endian) from an array of
;       bytes. 
;                                                                  
;
; CATEGORY:
;       Hansteen/Wikstol Data analysis SW
;
; CALLING SEQUENCE:
;       each of the functions are called in the same way, as an
;       example we use mkuintle:
;       uintleword = mkunitle(buf, is)
;
; INPUTS:
;       buf: The array of bytes from which to construct the words.
;       is: The position in buf from where to start.
;
; KEYWORD PARAMETERS:
;
;
; OUTPUTS:
;       unsigned 16, 24 or 32 bit words (littl or big endian)
;       depending on which functions is used.
;
; CALLS:
;       
;
; COMMON BLOCKS:
;       
;
; PROCEDURE:
;
;
; RESTRICTIONS:
;
;
; MODIFICATION HISTORY:
;       XX-Apr-2001: Viggo Hansteen,Oivind Wikstol
;       03-Oct-2001: Oivind Wikstol. Added documentation.
;-
function mkuint,buf,is
if n_elements(is) eq 0 then is = 0
b=ulong(2^8)
return,uint(b*buf(is+1)+buf(is))
end

function mkulong,buf,is
if n_elements(is) eq 0 then is = 0
b=ulong(2^8)
return,ulong(buf(is)+b*(buf(is+1)+b*(buf(is+2)+b*buf(is+3))))
end

function mku24,buf,is
if n_elements(is) eq 0 then is = 0
b=ulong(2^8)
return,ulong(buf(is)+b*(buf(is+1)+b*buf(is+2)))
end

function mkuintle,buf,is
if n_elements(is) eq 0 then is = 0
b=ulong(2^8)
return,uint(b*buf(is)+buf(is+1))
end

function mkulongle,buf,is
if n_elements(is) eq 0 then is = 0
b=ulong(2^8)
return,b*b*ulong(mkuintle(buf,is))+ulong(mkuintle(buf,is+2))
end

function mku24le,buf,is
if n_elements(is) eq 0 then is = 0
b=ulong(2^8)
return,ulong(buf(is+2)+b*(buf(is+1)+b*buf(is)))
end
