home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_12_04 / welstead / uisetcol.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-13  |  2.0 KB  |  83 lines

  1. Welstead: Listing 7
  2.  
  3. // UISETCOL.CPP Example of a typical function assigning
  4. //   setup structure fields to a TDataCollection
  5.  
  6. #ifndef UISETCOL_CPP
  7. #define UISETCOL.CPP
  8.  
  9. #include "uilstdlg.cpp"
  10.  
  11. typedef struct {
  12.       float error_threshold;
  13.       int no_of_inputs;
  14.       boolean input_weights_from_file;
  15.       path_str input_file_name;
  16.       } setup_record;
  17.  
  18. // Global setup record
  19. setup_record g_setup;
  20.  
  21. void setup_to_collection (setup_record *the_setup,
  22.    TDataCollection *the_collection)
  23.    {
  24.       void * value_ptr = NULL;
  25.       tdata_type the_type;
  26.       unsigned short len;
  27.       boolean the_check = TRUE;
  28.       unsigned short dec_places = 0;
  29.       float the_max = 0.0;
  30.       float the_min = 0.0;
  31.       boolean enable = TRUE;
  32.       int item_no = 0;
  33.  
  34.    value_ptr = &the_setup->error_threshold;
  35.    the_type = REAL_DATA;
  36.    len = 8;
  37.    dec_places = 6;
  38.    the_max = 1.0;
  39.    the_min = 1e-6;
  40.    item_no++;
  41.    the_collection->insert (new ttyped_data_obj (
  42.      "Error Threshold",
  43.      value_ptr,the_type,len,the_check,dec_places,
  44.      the_max,the_min,
  45.      enable,"",item_no));
  46.  
  47.    value_ptr = &the_setup->no_of_inputs;
  48.    the_type = INT_DATA;
  49.    len = 5;
  50.    dec_places = 0;
  51.    the_max = 100;
  52.    the_min = 1;
  53.    item_no++;
  54.    the_collection->insert (new ttyped_data_obj (
  55.      "No. of Inputs",
  56.      value_ptr,the_type,len,the_check,dec_places,
  57.      the_max,the_min,
  58.      enable,"",item_no));
  59.  
  60.    value_ptr = &the_setup->input_weights_from_file;
  61.    the_type = BOOLEAN_DATA;
  62.    len = 3;
  63.    item_no++;
  64.    the_collection->insert (new ttyped_data_obj (
  65.      "Input Wts from File?",
  66.      value_ptr,the_type,len,the_check,dec_places,
  67.      the_max,the_min,
  68.      enable,"",item_no));
  69.  
  70.    value_ptr = &the_setup->input_file_name;
  71.    the_type = PATH_DATA;
  72.    len = MAX_PATH;
  73.    item_no++;
  74.    the_collection->insert (new ttyped_data_obj (
  75.      "Input Wts File Name",
  76.      value_ptr,the_type,len,the_check,dec_places,
  77.      the_max,the_min,
  78.      enable,"*.WTS",item_no));
  79.    return;
  80.    }
  81.  
  82. #endif
  83.