pro MYDBBUILD, $ 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,$ v31, v32, v33, v34, v35, v36, v37, v38, v39, v40,$ v41, v42, v43, v44, v45, v46, v47, v48, v49, v50,$ v51, v52, v53, v54, v55, v56, v57, v58, v59, v60,$ v61, v62, v63, v64, v65, v66, v67, v68, v69, v70,$ v71, v72, v73, v74, v75, v76, v77, v78, v79, v80,$ v81, v82, v83, v84, v85, v86, v87, v88, v89, v90,$ v91, v92, v93, v94, v95, v96, v97, v98, v99,v100,$ NOINDEX = noindex, STATUS=STATUS, SILENT=SILENT ;+ ; NAME: ; MYDBBUILD ; ; NB : This is IDL astrolib's DBBUILD procedure modified to allow ; its use on catalogues of up to 100 columns (rather than 30) ; ; !!! SEE BELOW FOR ORIGINAL DBBUILD DOCUMENTATION AND CREDITS !!! ; ; 18 Nov 2006 - Extended to 100 columns by Mattia Vaccari ; ; PURPOSE: ; Build a database by appending new values for every item. ; ; EXPLANATION: ; The database must be opened for update (with DBOPEN) before calling ; MYDBBUILD. ; ; CALLING SEQUENCE: ; MYDBBUILD, [ v1, v2, v3, v4......v100, /NOINDEX, /SILENT, STATUS = ] ; ; INPUTS: ; v1,v2....v100 - 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 MYDBBUILD will ; *not* create an indexed file. Useful to save time if ; MYDBBUILD 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 MYDBBUILD ; 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 MYDBBUILD 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> mydbbuild,name,ra,dec,flux ;Write 4 vectors into the database ; ; NOTES: ; Do not call DBCREATE before MYDBBUILD if you want to append entries to ; an existing database ; ; MYDBBUILD 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 ;- COMPILE_OPT IDL2 On_error,2 ;Return to caller npar = N_params() if npar LT 1 then begin print,'Syntax - MYDBBUILD, v1, [ v2, v3, v4, v5, ... v100,' 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 nitem LE npar then message, 'ERROR - ' + strtrim(npar,2) + $ $ ' variables supplied but only ' + strtrim(nitem-1,2) + ' items in database' 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