resolve_routine and the IDL search path [message #35646] |
Fri, 27 June 2003 05:52 |
robert.dimeo
Messages: 42 Registered: November 2001
|
Member |
|
|
Hi,
I am having (what I believe are) path resolution difficulties. In a
runtime widget program I wish to have the user type in their own .PRO
file, save it, and press a button to compile it and run it. In a
fitting application I am working on I want the user to be able to
write their own complex fitting functions in IDL syntax that can be
compiled after the runtime application has been launched. When I run
this application in the IDLDE there are no problems because the new
.PRO file can be found and can be compiled with RESOLVE_ROUTINE. I
can then run the program by using CALL_PROCEDURE. However when I run
the program as a runtime application from a .SAV file I always get an
error message stating that states "ATTEMPT TO CALL UNDEFINED
PROCEDURE/FUNCTION: <.pro filename>".
I have distilled out the essential features of the code that generates
this problem in the short example below. Any thoughts would be
greatly appreciated!
Thanks,
Rob
Save the following file as DUMB_PLOT.PRO into a directory c:\my_dir\.
This is the file to be compiled at runtime upon pressing a button.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
pro dumb_plot
plot,findgen(10),psym = 4
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Save this main widget application as TEST_COMPILE.PRO. This is the
procedure that gets stored in a .SAV file and is run as a runtime
application.
pro test_compile_event,event
uname = widget_info(event.id,/uname)
case uname of
'QUIT': widget_control,event.top,/destroy
'PLOT': begin
catch,theError
if theError ne 0 then begin
catch,/cancel
ok = dialog_message(!error_state.msg,/error)
return
endif
this_file = 'dumb_plot'
strout = 'Valid file: '+string(file_test(this_file+'.pro'))
void = dialog_message(dialog_parent = event.top, $
strout,/info)
resolve_routine,this_file+'.pro'
call_procedure,this_file
end
else:
endcase
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;
pro test_compile
; The location of this file is in the directory shown below.
; Note also that the IDL procedure called DUMB_PLOT.PRO is located
; in this directory too. When I compile and save the file as a .SAV
; file I store it in this directory as TEST_COMPILE.SAV.
dir = 'c:\my_dir'
cd,dir
!path = !path + path_sep(/search_path)+dir
tlb = widget_base(/col,title = 'TEST APPLICATION',/tlb_frame_attr)
void = widget_button(tlb,value = 'QUIT',uname = 'QUIT')
void = widget_button(tlb,value = 'COMPILE DUMB_PLOT.PRO AND RUN', $
uname = 'PLOT')
widget_control,tlb,/realize
xmanager,'test_compile',tlb,/no_block
end
|
|
|