pro dbbuild,v1,v2,v3,v4,v5,v6,v7,v8,v9,v10,v11,v12,v13,v14,v15,v16,v17,v18, $ v19,v20,v21,v22,v23,v24,v25,v26,v27,v28,v29,v30, $ NOINDEX = noindex, STATUS=STATUS, SILENT=SILENT ;+ ; NAME: ; DBBUILD ; PURPOSE: ; Build a database by appending new values for every item. ; EXPLANATION: ; The database must be opened for update (with DBOPEN) before calling ; DBBUILD. ; ; CALLING SEQUENCE: ; DBBUILD, [ v1, v2, v3, v4......v30, /NOINDEX, /SILENT, STATUS = ] ; ; INPUTS: ; v1,v2....v30 - vectors containing values for all items in the database. ; V1 contains values for the first item, V2 for the second, etc. ; The number of vectors supplied must equal the number of items ; (excluding entry number) in the database. The number of elements ; in each vector should be the same. A multiple valued item ; should be dimensioned NVALUE by NENTRY, where NVALUE is the number ; of values, and NENTRY is the number of entries. ; ; OPTIONAL INPUT KEYWORDS: ; NOINDEX - If this keyword is supplied and non-zero then DBBUILD will ; *not* create an indexed file. Useful to save time if ; DBBUILD is to be called several times and the indexed file need ; only be created on the last call ; ; SILENT - If the keyword SILENT is set and non-zero, then DBBUILD ; will not print a message when the index files are generated ; ; OPTIONAL OUTPUT KEYWORD: ; STATUS - Returns a status code denoting whether the operation was ; successful (1) or unsuccessful (0). Useful when DBBUILD is ; called from within other applications. ; ; EXAMPLE: ; Suppose a database named STARS contains the four items NAME,RA,DEC, and ; FLUX. Assume that one already has the four vectors containing the ; values, and that the database definition (.DBD) file already exists. ; ; IDL> !PRIV=2 ;Writing to database requires !PRIV=2 ; IDL> dbcreate,'stars',1,1 ;Create database (.DBF) & index (.DBX) file ; IDL> dbopen,'stars',1 ;Open database for update ; IDL> dbbuild,name,ra,dec,flux ;Write 4 vectors into the database ; ; NOTES: ; Do not call DBCREATE before DBBUILD if you want to append entries to ; an existing database ; ; DBBUILD checks that each value vector matches the idl type given in the ; database definition (.DBD) file, and that character strings are the ; proper length. ; REVISION HISTORY: ; Written W. Landsman March, 1989 ; Added /NOINDEX keyword W. Landsman November, 1992 ; User no longer need supply all items W. Landsman December, 1992 ; Added STATUS keyword, William Thompson, GSFC, 1 April 1994 ; Added /SILENT keyword, William Thompson, GSFC, October 1995 ; Allow up to 30 items, fix problem if first item was multiple value ; W. Landsman GSFC, July 1996 ; Faster build of external databases on big endian machines ; W. Landsman GSFC, November 1997 ; Converted to IDL V5.0 W. Landsman 24-Nov-1997 ; Use SIZE(/TNAME) for error mesage display W.Landsman July 2001 ; Fix message display error introduced July 2001 W. Landsman Oct. 2001 ;- On_error,2 ;Return to caller npar = N_params() if npar LT 1 then begin print,'Syntax - DBBUILD, v1, [ v2, v3, v4, v5, ... v30,' print,' /NOINDEX, /SILENT, STATUS = ]' return endif dtype = ['UNDEFINED','BYTE','INTEGER*2','INTEGER*4','REAL*4','REAL*8', $ 'COMPLEX','STRING','STRUCTURE','DCOMPLEX','POINTER','OBJECT', $ 'UNSIGNED*2', 'UNSIGNED*4', 'INTEGER*8','UNSIGNED*8'] ; Initialize STATUS as unsuccessful (0). If the routine is successful, this ; will be updated below. status = 0 nitem = db_info( 'ITEMS' ) if N_elements( nitem ) EQ 0 then return items = indgen(nitem) db_item, items, itnum, ivalnum, idltype, sbyte, numvals, nbyte for i = 1,npar do begin ;Get the dimensions and type of each input vector ii = strtrim(i,2) test = execute('s=size(v' + ii +')' ) if s[s[0] + 1] NE idltype[i] then begin message, 'Item ' + strtrim( db_item_info('NAME',i),2) + $ ' - parameter '+strtrim(i,2) + ' - has an incorrect data type',/INF message, 'Required data type is ' + dtype(idltype[i]), /INF message, 'Supplied data type is ' + dtype(s[s[0]+1]), /INF return endif endfor external = db_info('external',0) if external then noconvert = is_ieee_big() else noconvert = 1b nitems = ( (npar