1 | ;------------------------------------------------------------ |
---|
2 | ;------------------------------------------------------------ |
---|
3 | ;------------------------------------------------------------ |
---|
4 | ;+ |
---|
5 | ; NAME:createpro |
---|
6 | ; |
---|
7 | ; PURPOSE:ecrit un .pro le compile et l''execute |
---|
8 | ; |
---|
9 | ; CATEGORY: |
---|
10 | ; |
---|
11 | ; CALLING SEQUENCE:createpro, command |
---|
12 | ; |
---|
13 | ; INPUTS: |
---|
14 | ; command:un vecteur de string contenant les intructions a |
---|
15 | ; passer pour construire la procedure |
---|
16 | ; |
---|
17 | ; KEYWORD PARAMETERS: |
---|
18 | ; filenamein: un string donnant le nom de la procedure a ecrire |
---|
19 | ; |
---|
20 | ; OUTPUTS: |
---|
21 | ; |
---|
22 | ; COMMON BLOCKS: |
---|
23 | ; |
---|
24 | ; SIDE EFFECTS:complete filename par '.pro' si besion |
---|
25 | ; |
---|
26 | ; RESTRICTIONS:de marche pas pour les fonctions |
---|
27 | ; |
---|
28 | ; EXAMPLE: |
---|
29 | ; IDL> createpro, ['print,''OK'''],filename='test' |
---|
30 | ; |
---|
31 | ; MODIFICATION HISTORY:Sebastien Masson (smasson@lodyc.jussieu.fr) |
---|
32 | ; |
---|
33 | ;- |
---|
34 | ;------------------------------------------------------------ |
---|
35 | ;------------------------------------------------------------ |
---|
36 | ;------------------------------------------------------------ |
---|
37 | PRO createpro, command, filenamein = filenamein |
---|
38 | |
---|
39 | if NOT keyword_set(filenamein) then filename = 'for_createpro.pro' $ |
---|
40 | ELSE BEGIN |
---|
41 | filename = filenamein |
---|
42 | if rstrpos(filename, '.pro') NE strlen(filename)-4 then $ |
---|
43 | filename = filename+'.pro' |
---|
44 | ENDELSE |
---|
45 | shortfilename = strmid(filename, 0, strlen(filename)-4) |
---|
46 | thisOS = strupcase(strmid(!version.os_family, 0, 3)) |
---|
47 | CASE thisOS of |
---|
48 | 'MAC':sep = ':' |
---|
49 | 'WIN':sep = '\' |
---|
50 | ELSE:sep = '/' |
---|
51 | ENDCASE |
---|
52 | shortfilename = strmid(shortfilename, rstrpos(shortfilename, sep)+1) |
---|
53 | if rstrpos(shortfilename, sep) GE 1 then begin |
---|
54 | directory = strmid(filename, 0, rstrpos(shortfilename, sep)) |
---|
55 | directory = isadirectory(io = directory, $ |
---|
56 | title = 'Bad definition of Directory: '+directory) |
---|
57 | endif |
---|
58 | putfile, filename, ['pro '+shortfilename, command, 'return', 'end'] |
---|
59 | resolve_routine, shortfilename |
---|
60 | rien = execute(shortfilename) |
---|
61 | return |
---|
62 | end |
---|