;+ ; ; @file_comments ; Concatenate 2 structures together. The difference with CREATE_STRUCT ; is that if the 2 structure have same elements's name, then mixstru ; do not break down but choose for the common element the value ; specified by the first structure. ; ; @categories ; Structure ; ; @param STRU1 {in}{required} ; Structure which can have same elements's name than ; STRU2 but with a different value. ; ; @param STRU2 {in}{required} ; Structure which can have same elements's name than ; STRU1 but with a different value. ; ; @returns ; A structure ; ; @restrictions ; If STRU1 or STRU2 is not a structure, mixstru send back -1 ; ; @examples ; ; IDL> a=get_extra(/toto,ok=123) ; IDL> b=get_extra(ok=111, year=1999, age_capitaine=35) ; IDL> help, a,b,/struct ; ** Structure <8334424>, 2 tags, length=4, refs=1: ; OK INT 123 ; TOTO INT 1 ; ** Structure <8373da4>, 3 tags, length=6, refs=1: ; AGE_CAPITAINE INT 35 ; OK INT 111 ; YEAR INT 1999 ; IDL> help, mixstru(a,b),/struct ; ** Structure <82f25ac>, 4 tags, length=8, refs=1: ; AGE_CAPITAINE INT 35 ; YEAR INT 1999 ; OK INT 123 ; TOTO INT 1 ; IDL> help, mixstru(b,a),/struct ; ** Structure <834604c>, 4 tags, length=8, refs=1: ; TOTO INT 1 ; AGE_CAPITAINE INT 35 ; OK INT 111 ; YEAR INT 1999 ; ; @history ; Sebastien Masson (smasson\@lodyc.jussieu.fr) ; 7/10/1999 ; ; @version ; $Id$ ; ;- ; FUNCTION mixstru, stru1, stru2 ; compile_opt idl2, strictarrsubs ; @cm_general IF size(stru1, /type) EQ 0 AND size(stru2, /type) EQ 8 THEN return, stru2 IF size(stru2, /type) EQ 0 AND size(stru1, /type) EQ 8 THEN return, stru1 if size(stru1, /type) NE 8 then return, -1 if size(stru2, /type) NE 8 then return, -1 tname = tag_names(stru2) str = '' FOR i = 0, n_tags(stru2)-1 DO str = str + tname[i]+' = stru2.(' + strtrim(i, 2)+ '), ' res = createfunc('get_extra('+str+'_extra = stru1)' $ , kwdlist = 'stru1 = stru1, stru2 = stru2' $ , stru1 = stru1, stru2 = stru2 $ , filename = myuniquetmpdir +'for_createfunc.pro') return, res end