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