home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / external / callable / calltest.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-07-08  |  1.2 KB  |  48 lines

  1. #include <stdio.h>
  2. #include "export.h"
  3.  
  4.  
  5.  
  6. static void free_callback(UCHAR *addr)
  7. {
  8.   printf("IDL released(%u)\r\n", addr);
  9. }
  10.  
  11.  
  12.  
  13. int main(int argc, char **argv)
  14. {
  15.   float f[10];
  16.   int i;
  17.   IDL_VPTR v;
  18.   IDL_LONG dim[IDL_MAX_ARRAY_DIM];
  19.   static char *cmds[] = { "tmp2 = total(tmp)", "print,'IDL total is ', tmp2",
  20.                 "plot,tmp" };
  21.   static char *cmds2[] = { "a = widget_base()",
  22.      "b = widget_button(a, value='Press When Done', xsize=300, ysize=200)",
  23.      "widget_control,/realize, a",
  24.      "dummy = widget_event(a)",
  25.      "widget_control,/destroy, a" };
  26.   
  27.  
  28.   for (i=0; i < 10; i++) f[i] = (float) i;
  29.   if (IDL_Init(0, &argc, argv)) {
  30.     dim[0] = 10;
  31.     printf("ARRAY ADDRESS(%u)\r\n", f);
  32.     if (v = IDL_ImportNamedArray("TMP", 1, dim, IDL_TYP_FLOAT, (UCHAR *) f,
  33.                  free_callback, (void *) 0)) {
  34.       (void) IDL_ExecuteStr("print, tmp");
  35.       (void) IDL_Execute(sizeof(cmds)/sizeof(char *), cmds);
  36.       (void) IDL_ExecuteStr("print, 'This should free the user memory");
  37.       (void) IDL_ExecuteStr("tmp = 0");
  38.       if (v = IDL_FindNamedVariable("tmp2", FALSE))
  39.     printf("Program total is %f\n\r", v->value.f);
  40.       (void) IDL_Execute(sizeof(cmds2)/sizeof(char *), cmds2);
  41.       IDL_Cleanup(FALSE);    /* Don't return */
  42.     }
  43.   }
  44.  
  45.   return 1;
  46. }
  47.  
  48.