[2] | 1 | ;+ |
---|
| 2 | ; |
---|
[150] | 3 | ; @file_comments |
---|
| 4 | ; Concatenate 2 structures together. The difference with CREATE_STRUCT |
---|
| 5 | ; is that if the 2 structure have same elements's name, then mixstru |
---|
| 6 | ; do not break down but choose for the common element the value |
---|
| 7 | ; specified by the first structure. |
---|
[2] | 8 | ; |
---|
[150] | 9 | ; @categories |
---|
[157] | 10 | ; Structure |
---|
[2] | 11 | ; |
---|
[150] | 12 | ; @param STRU1 {in}{required} |
---|
| 13 | ; Structure which can have same elements's name than |
---|
| 14 | ; STRU2 but with a different value. |
---|
[2] | 15 | ; |
---|
[150] | 16 | ; @param STRU2 {in}{required} |
---|
| 17 | ; Structure which can have same elements's name than |
---|
| 18 | ; STRU1 but with a different value. |
---|
[2] | 19 | ; |
---|
[150] | 20 | ; @returns |
---|
[163] | 21 | ; A structure |
---|
[2] | 22 | ; |
---|
[150] | 23 | ; @restrictions |
---|
| 24 | ; If STRU1 or STRU2 is not a structure, mixstru send back -1 |
---|
[2] | 25 | ; |
---|
[150] | 26 | ; @examples |
---|
[2] | 27 | ; |
---|
| 28 | ; IDL> a=get_extra(/toto,ok=123) |
---|
| 29 | ; IDL> b=get_extra(ok=111, year=1999, age_capitaine=35) |
---|
| 30 | ; IDL> help, a,b,/struct |
---|
| 31 | ; ** Structure <8334424>, 2 tags, length=4, refs=1: |
---|
| 32 | ; OK INT 123 |
---|
| 33 | ; TOTO INT 1 |
---|
| 34 | ; ** Structure <8373da4>, 3 tags, length=6, refs=1: |
---|
| 35 | ; AGE_CAPITAINE INT 35 |
---|
| 36 | ; OK INT 111 |
---|
| 37 | ; YEAR INT 1999 |
---|
| 38 | ; IDL> help, mixstru(a,b),/struct |
---|
| 39 | ; ** Structure <82f25ac>, 4 tags, length=8, refs=1: |
---|
| 40 | ; AGE_CAPITAINE INT 35 |
---|
| 41 | ; YEAR INT 1999 |
---|
| 42 | ; OK INT 123 |
---|
| 43 | ; TOTO INT 1 |
---|
| 44 | ; IDL> help, mixstru(b,a),/struct |
---|
| 45 | ; ** Structure <834604c>, 4 tags, length=8, refs=1: |
---|
| 46 | ; TOTO INT 1 |
---|
| 47 | ; AGE_CAPITAINE INT 35 |
---|
| 48 | ; OK INT 111 |
---|
| 49 | ; YEAR INT 1999 |
---|
| 50 | ; |
---|
[150] | 51 | ; @history |
---|
[157] | 52 | ; Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
[2] | 53 | ; 7/10/1999 |
---|
[150] | 54 | ; |
---|
| 55 | ; @version |
---|
| 56 | ; $Id$ |
---|
| 57 | ; |
---|
[2] | 58 | ;- |
---|
[232] | 59 | ; |
---|
[2] | 60 | FUNCTION mixstru, stru1, stru2 |
---|
[114] | 61 | ; |
---|
| 62 | compile_opt idl2, strictarrsubs |
---|
| 63 | ; |
---|
[74] | 64 | @cm_general |
---|
| 65 | |
---|
[2] | 66 | IF size(stru1, /type) EQ 0 AND size(stru2, /type) EQ 8 THEN return, stru2 |
---|
| 67 | IF size(stru2, /type) EQ 0 AND size(stru1, /type) EQ 8 THEN return, stru1 |
---|
| 68 | if size(stru1, /type) NE 8 then return, -1 |
---|
| 69 | if size(stru2, /type) NE 8 then return, -1 |
---|
| 70 | tname = tag_names(stru2) |
---|
[74] | 71 | |
---|
| 72 | str = '' |
---|
| 73 | FOR i = 0, n_tags(stru2)-1 DO str = str + tname[i]+' = stru2.(' + strtrim(i, 2)+ '), ' |
---|
| 74 | |
---|
| 75 | res = createfunc('get_extra('+str+'_extra = stru1)' $ |
---|
| 76 | , kwdlist = 'stru1 = stru1, stru2 = stru2' $ |
---|
| 77 | , stru1 = stru1, stru2 = stru2 $ |
---|
| 78 | , filename = myuniquetmpdir +'for_createfunc.pro') |
---|
| 79 | |
---|
[2] | 80 | return, res |
---|
[74] | 81 | |
---|
[2] | 82 | end |
---|