source: trunk/SRC/ToBeReviewed/STRUCTURE/mixstru.pro @ 134

Last change on this file since 134 was 134, checked in by navarro, 18 years ago

change *.pro file properties (del eof-style, del executable, set keywords Id

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.8 KB
Line 
1;------------------------------------------------------------
2;------------------------------------------------------------
3;------------------------------------------------------------
4;+
5; NAME: mixstru
6;
7; PURPOSE: concatene 2 structures ensemble. La difference avec
8; CREATE_STRUCT etant que si les 2 stuctures ont les memes noms
9; d''elements alors mixstru ne plante pas mais choisit pour valeur de
10; l''element commun celle specifiee par la premiere structure.
11;
12; CATEGORY: structure
13;
14; CALLING SEQUENCE: rs=mixstru(stru1,stru2)
15;
16; INPUTS: stru1 et stu2 sont 2 structures qui peuvent avoir des
17; elements portant le meme nom mais avec une valeur differente.
18;
19; KEYWORD PARAMETERS: none
20;
21; OUTPUTS: une stucture
22;
23; COMMON BLOCKS:
24;
25; SIDE EFFECTS: si stru1 ou stru2 ne sont pas des structures mixstru
26; renvoie -1
27;
28; RESTRICTIONS:
29;
30; EXAMPLE:
31;     
32;     IDL> a=get_extra(/toto,ok=123)
33;     IDL> b=get_extra(ok=111, year=1999, age_capitaine=35)
34;     IDL> help, a,b,/struct
35;     ** Structure <8334424>, 2 tags, length=4, refs=1:
36;        OK              INT            123
37;        TOTO            INT              1
38;     ** Structure <8373da4>, 3 tags, length=6, refs=1:
39;        AGE_CAPITAINE   INT             35
40;        OK              INT            111
41;        YEAR            INT           1999
42;     IDL> help, mixstru(a,b),/struct
43;     ** Structure <82f25ac>, 4 tags, length=8, refs=1:
44;        AGE_CAPITAINE   INT             35
45;        YEAR            INT           1999
46;        OK              INT            123
47;        TOTO            INT              1
48;     IDL> help, mixstru(b,a),/struct
49;     ** Structure <834604c>, 4 tags, length=8, refs=1:
50;        TOTO            INT              1
51;        AGE_CAPITAINE   INT             35
52;        OK              INT            111
53;        YEAR            INT           1999
54;
55; MODIFICATION HISTORY:Sebastien Masson (smasson@lodyc.jussieu.fr)
56;                      7/10/1999
57;-
58;------------------------------------------------------------
59;------------------------------------------------------------
60;------------------------------------------------------------
61FUNCTION mixstru, stru1, stru2
62;
63  compile_opt idl2, strictarrsubs
64;
65@cm_general
66
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)
72   
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
81   return, res
82
83end
Note: See TracBrowser for help on using the repository browser.