;------------------------------------------------------------ ;------------------------------------------------------------ ;------------------------------------------------------------ ;+ ; NAME: mixstru ; ; PURPOSE: concatene 2 structures ensemble. La difference avec ; CREATE_STRUCT etant que si les 2 stuctures ont les memes noms ; d''elements alors mixstru ne plante pas mais choisit pour valeur de ; l''element commun celle specifiee par la premiere structure. ; ; CATEGORY: structure ; ; CALLING SEQUENCE: rs=mixstru(stru1,stru2) ; ; INPUTS: stru1 et stu2 sont 2 structures qui peuvent avoir des ; elements portant le meme nom mais avec une valeur differente. ; ; KEYWORD PARAMETERS: none ; ; OUTPUTS: une stucture ; ; COMMON BLOCKS: ; ; SIDE EFFECTS: si stru1 ou stru2 ne sont pas des structures mixstru ; renvoie -1 ; ; RESTRICTIONS: ; ; EXAMPLE: ; ; 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 ; ; MODIFICATION HISTORY:Sebastien Masson (smasson@lodyc.jussieu.fr) ; 7/10/1999 ;- ;------------------------------------------------------------ ;------------------------------------------------------------ ;------------------------------------------------------------ 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