                                Source Listing                   8-SEP-1993 14:22:34    DEC C V1.3-000A                     Page   1
                                                                 8-SEP-1993 14:22:32    SMGVT220FIX.C;25

	      1 #include <stsdef>
	    129 #include <iodef>
	   1088 #include <dcdef>
	   1727 #include <ttdef>
	   2006 #include <descrip>
	   2477 #include <smgdef>
	   4981 #include <string>
	   5107 
	   5108 int kb_id;
	   5109 int pb_id;
	   5110 int menu_vd_id;
	   5111 int smg_stat;
	   5112 int      menu_vd_attr = SMG$M_BORDER,
	   5113          menu_vd_row_count = 12,
	   5114          menu_vd_col_count = 20,
	   5115          menu_vd_prow      =  8,
	   5116          menu_vd_pcol      = 60;
	   5117 
	   5118 unsigned long int
	   5119          menu_type         = SMG$K_VERTICAL;
	   5120 
	   5121 struct dsc$descriptor_s s_descr;
	   5122 struct dsc$descriptor_s *s_descrip(char *string_ptr);
	   5123 struct dsc$descriptor_a ch_arr_descr;
	   5124 struct dsc$descriptor_a *a_descrip(char *str_array_ptr);
	   5125 
	   5126 int smg$create_pasteboard();
	   5127 int smg$control_mode();
	   5128 int smg$create_virtual_display();
	   5129 int smg$create_virtual_keyboard();
	   5130 int smg$create_menu();
	   5131 int smg$paste_virtual_display();
	   5132 int smg$select_from_menu();
	   5133 void set_term();
	   5134 int sys$assign();
	   5135 int sys$qiow();
	   5136 int lib$signal();
	   5137 
	   5138 
	   5139 #define  MENU_ITEM_COUNT       10
	   5140 #define  MAX_MENU_ITEM_SIZE    20
	   5141 main()
	   5142 {
	   5143    int mode;
	   5144    int i,j;
	   5145    unsigned short int menu_choice;
	   5146    char menu_items[MENU_ITEM_COUNT][MAX_MENU_ITEM_SIZE];
	   5147 
	   5148    smg_stat = smg$create_pasteboard(&pb_id);
	   5149 
	   5150    smg_stat = smg$control_mode(&pb_id, 0, &mode);
	   5151    mode = mode | SMG$M_NOTABS;	   /* DISABLE USE OF TABS */
	   5152    smg_stat = smg$control_mode(&pb_id, &mode);
	   5153 
	   5154    smg_stat = smg$create_virtual_display(&menu_vd_row_count,&menu_vd_col_count,
	   5155                                          &menu_vd_id,&menu_vd_attr);
	   5156 

                                Source Listing                   8-SEP-1993 14:22:34    DEC C V1.3-000A                     Page   2
                                                                 8-SEP-1993 14:22:32    SMGVT220FIX.C;25

	   5157    set_term(0);  /* set terminal to VT100 if it's a VT200 (bugfix "}z") */
	   5158    smg_stat = smg$create_virtual_keyboard(&kb_id);
	   5159    set_term(1);  /* reset terminal if it was changed above (bugfix "}z") */
	   5160 
	   5161    for (i = 0; i < MENU_ITEM_COUNT; i++)
	   5162       for (j = 0; j < MAX_MENU_ITEM_SIZE; j++)
	   5163          menu_items[i][j] = 0;
	   5164 
	   5165    strcpy(menu_items[0],"Wafer Maps");
	   5166    strcpy(menu_items[1],"Start Slice Lots");
	   5167    strcpy(menu_items[2],"Start Slider Lots");
	   5168    strcpy(menu_items[3],"Print SFA Labels");
	   5169    strcpy(menu_items[4],"Special Functions");
	   5170    strcpy(menu_items[5],"Exit");
	   5171    smg_stat = smg$create_menu(&menu_vd_id,a_descrip((char *)&menu_items),&menu_type);
	   5172    smg$paste_virtual_display(&menu_vd_id,&pb_id,&menu_vd_prow,&menu_vd_pcol);
	   5173    smg$select_from_menu(&kb_id,&menu_vd_id,&menu_choice);
	   5174 }
	   5175 
	   5176 void set_term( int reset)
	   5177 /* reset = 0 - change to VT100.  1 - change back to previous setting.
	   5178    This fixes a problem with non-DIGITAL brand VT200 terminals.  True DIGITAL
	   5179    VT200 terminals accept a few extra escape sequences.  These show up as
	   5180    "}z" glitches on other VT200 terminals.  The fix is to tell SMG that
	   5181    we're a VT100.  If we're a VT200 terminal we switch to a VT100 terminal,
	   5182    initialize SMG, and switch back to a VT200 terminal.  SET_TERM is
	   5183    sandwiched around the call to SMG$CREATE_VIRTUAL_KEYBOARD (for detailed
	   5184    technical reasons.) as follows:
	   5185 
	   5186    set_term(0);
	   5187    smg_stat = smg$create_virtual_keyboard(&kb_id);
	   5188    set_term(1);
	   5189 */
	   5190 {
	   5191    int status;
	   5192    static short int input_chan;	/* I/O channel */
	   5193    static int term_changed;	/* set to 1 if terminal modified */
	   5194 
	   5195    /* I/O status block */
	   5196    struct iostat_block {
	   5197       short int iostat;
	   5198       char      transmit;
	   5199       char      receive;
	   5200       char      crfill;
	   5201       char      lffill;
	   5202       char      parity;
	   5203       char      zero;
	   5204    } iosb;
	   5205 
	   5206    /* Characteristics buffer
	   5207       Note: basic characteristics are first three bytes of second longword
	   5208             length is last byte */
	   5209    struct characteristics {
	   5210       char      class;
	   5211       char      type;
	   5212       short int width;
	   5213       int       basic;

                                Source Listing                   8-SEP-1993 14:22:34    DEC C V1.3-000A                     Page   3
                                                                 8-SEP-1993 14:22:32    SMGVT220FIX.C;25

	   5214       int       extended;
	   5215    };
	   5216   static struct characteristics charbuf;	/* save old characteristics */
	   5217   auto struct characteristics newcharbuf;
	   5218 
	   5219    /* begin */
	   5220    if (reset == 0)
	   5221    {
	   5222       /* SEE IF TERMINAL IS A VT200 SERIES */
	   5223       /* Assign channel to terminal */
	   5224       if (input_chan == 0) {
	   5225          status = sys$assign (s_descrip("SYS$INPUT"), &input_chan, 0, 0);
	   5226          if ( !(status & STS$M_SUCCESS) ) lib$signal(status);
	   5227       }
	   5228 
	   5229       /* Get current characteristics */
	   5230       status = sys$qiow ( 0, input_chan, IO$_SENSEMODE, &iosb, 0, 0,
	   5231                           &charbuf,         /* Buffer */
	   5232                           12,               /* Buffer size */
	   5233                           0, 0, 0, 0);
	   5234       if ( !(status & STS$M_SUCCESS) ) lib$signal(status);
	   5235       if ( !(iosb.iostat & STS$M_SUCCESS)) lib$signal(iosb.iostat);
	   5236 
	   5237       /* Check for terminal */
	   5238       if (charbuf.class != DC$_TERM) return;
	   5239 
	   5240       /* Check for VT200 */
	   5241       if (charbuf.type != TT$_VT200_SERIES) return;
	   5242 
	   5243       /* Set new characteristics */
	   5244       newcharbuf = charbuf;
	   5245       newcharbuf.type = TT$_VT100;
	   5246       status = sys$qiow ( 0, input_chan, IO$_SETMODE, &iosb, 0, 0,
	   5247                           &newcharbuf,      /* Buffer */
	   5248                           12,               /* Buffer size */
	   5249                           0, 0, 0, 0);
	   5250       if ( !(status & STS$M_SUCCESS) ) lib$signal(status);
	   5251       if ( !(iosb.iostat & STS$M_SUCCESS)) lib$signal(iosb.iostat);
	   5252       term_changed = 1;
	   5253    }
	   5254    else    /* else reset terminal to previous characteristics */
	   5255    {
	   5256       if (term_changed = 1)
	   5257       {
	   5258          status = sys$qiow ( 0, input_chan, IO$_SETMODE, &iosb, 0, 0,
	   5259                              &charbuf,         /* Buffer */
	   5260                              12,               /* Buffer size */
	   5261                              0, 0, 0, 0);
	   5262          if ( !(status & STS$M_SUCCESS) ) lib$signal(status);
	   5263          if ( !(iosb.iostat & STS$M_SUCCESS)) lib$signal(iosb.iostat);
	   5264          term_changed = 0;
	   5265       }/*endif*/
	   5266    }/*endif*/
	   5267 }
	   5268 
	   5269 struct dsc$descriptor_s *s_descrip(char *str_ptr)
	   5270 {

                                Source Listing                   8-SEP-1993 14:22:34    DEC C V1.3-000A                     Page   4
                                                                 8-SEP-1993 14:22:32    SMGVT220FIX.C;25

	   5271    s_descr.dsc$w_length  = strlen(str_ptr);
	   5272    s_descr.dsc$b_class   = DSC$K_CLASS_S;
	   5273    s_descr.dsc$b_dtype   = DSC$K_DTYPE_T;
	   5274    s_descr.dsc$a_pointer = str_ptr;
	   5275    return &s_descr;
	   5276 }
	   5277 
	   5278 struct dsc$descriptor_a *a_descrip(char *str_array_ptr)
	   5279 {
	   5280    int a_size;
	   5281 
	   5282    a_size = MAX_MENU_ITEM_SIZE * MENU_ITEM_COUNT;
	   5283 
	   5284    ch_arr_descr.dsc$w_length  = MAX_MENU_ITEM_SIZE;
	   5285    ch_arr_descr.dsc$b_dtype   = DSC$K_DTYPE_T;
	   5286    ch_arr_descr.dsc$b_class   = DSC$K_CLASS_A;
	   5287    ch_arr_descr.dsc$a_pointer = str_array_ptr;
	   5288    ch_arr_descr.dsc$b_aflags.dsc$v_fl_bounds = 0;
	   5289    ch_arr_descr.dsc$b_dimct   = 1;
	   5290    ch_arr_descr.dsc$l_arsize  = a_size;
	   5291 
	   5292    return &ch_arr_descr;
	   5293 }


Command Line
------- ----

CC /ANSI_ALIAS/ASSUME=(ACCURACY_SENSITIVE,ALIGNED_OBJECTS,NOWRITABLE_STRING_LITERALS)
/DEBUG=(SYMBOLS,TRACEBACK)/ENDIAN=LITTLE/EXTERN_MODEL=RELAXED_REFDEF/FLOAT=G_FLOAT
/GRANULARITY=QUADWORD/INSTRUCTION_SET=FLOATING_POINT/LIST/NOMACHINE_CODE
/MEMBER_ALIGNMENT/NAMES=UPPERCASE/NESTED_INCLUDE_DIRECTORY=PRIMARY_FILE
/OBJECT/NOOPTIMIZE/PREFIX=(ANSI_C89_ENTRIES)/SHOW=(HEADER,SOURCE)/SIGNED_CHAR
/STANDARD=RELAXED_ANSI89/REENTRANCY=TOLERANT/WARNINGS
