home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 1 / crawlyvol1.bin / apps / spread / opusprg / opussrc / w.pas < prev    next >
Pascal/Delphi Source File  |  1988-05-12  |  30KB  |  756 lines

  1.  
  2.  
  3. {$M+}
  4. {$E+}
  5.  
  6. PROGRAM name;
  7.  
  8. {$I i:\opus.i}
  9. {$I i:\gctv.inc}
  10.  
  11. {$I i:\gemsubs.def}
  12. {$I i:\vdi_aes.def}
  13.  
  14. PROCEDURE HELP ( what : INTEGER );
  15.    EXTERNAL;
  16. FUNCTION VALID_NUMBER ( VAR str : LorFstr ) : StatusType;
  17.    EXTERNAL;
  18. PROCEDURE CELL_ON_SCREEN ( a,b,c : INTEGER; d : BOOLEAN );
  19.    EXTERNAL;
  20. PROCEDURE WRITE_CELL_NAME;
  21.    EXTERNAL;
  22. PROCEDURE DELETE_CELL ( row,col : INTEGER; total_kill : BOOLEAN );
  23.    EXTERNAL;
  24. FUNCTION LOCATE_CELL ( row,col : INTEGER ) : CellPtr;
  25.    EXTERNAL;
  26. FUNCTION MOUSE_ROW_COL ( mouse_x,mouse_y     : INTEGER;
  27.                          VAR new_row,new_col : INTEGER ) : BOOLEAN;
  28.    EXTERNAL;
  29. PROCEDURE DEFAULT_DRAW_ATTRIBUTES;
  30.    EXTERNAL;
  31. PROCEDURE INT_TO_STRING ( a : INTEGER; VAR b : STR10 );
  32.    EXTERNAL; { found in NUM_CON.PAS }
  33. PROCEDURE UNHIDE ( menu : Tree_Index );
  34.    EXTERNAL;
  35. PROCEDURE HIDE;
  36.    EXTERNAL;
  37.  
  38. PROCEDURE WINDOW_INPUT ( max_length     : INTEGER;
  39.                          str_type       : InpType; { Alphanumeric,FloatingPoint
  40.                                                      AnInteger ( not used ) }
  41.                          VAR str        : STR255 );
  42.  
  43. { expects a visible mouse }
  44. { global variables used:
  45.      msg_area,too_long,float,area_x,area_y,area_w,area_h,
  46.      null_input,inp_code,column,char_count,key,
  47.      x_pix,mx,my,bad_str,event,alert,pos_in_str,btn_state,b_cnt,
  48.      edit_x,edit_y
  49. }
  50.  
  51.  
  52. { null_input & inp_code are specific parms I added to this general-purpose
  53.   routine. null_input as passed represents whether or not the passed formula
  54.   is valid or not. It returns TRUE if the user made no changes,
  55.   regardless of str-type.
  56.   inp_code
  57.   is a variable which returns various key actions independent of str, i.e.
  58.   a cursor key or RETURN was pressed, and also all other key actions
  59.   defined in CHECK_KEY. adding new key functions requires:
  60.      1. defining new constant in file windinp.cns,
  61.      2. updating CHECK_KEY,
  62.      3. updating NOT_EXIT_KEY.
  63.   For this application, the LEFT_ARROW, etc. functions are invoked by
  64.   CNTL-cursor instead of just the cursor. Need to keep this in mind for
  65.   using this routine elsewhere }
  66.  
  67.   { we could check for invalid numbers on the fly, as they are entered,
  68.     character by character, but suppose the user isn't paying attention
  69.     to what he has entered. A misplaced - sign or decimal could be entered, &
  70.     he would continue. Then he goes on to complete the number, tries to enter
  71.     the - sign or decimal where he intended, and isn't allowed to because
  72.     it would be invalid; moreover he isn't alerted to this- he wouldn't want an
  73.     alert box every time he made a mistake. He
  74.     has made an error and doesn't know it. So, to avoid this, we allow only
  75.     valid digits in the number, and once the number is locked in, we check
  76.     its validity; if invalid, i.e. > 1 dec points, > 1 E's, etc.,
  77.     an alert box appears. }
  78.  
  79.   LABEL 5,100;
  80.   CONST line_length = 31;
  81.   VAR
  82.         i,j,dummy,str_pos,
  83.         line_count,y_pix,y_dis  : INTEGER;
  84.         first,quit,ins          : BOOLEAN;
  85.  
  86. FUNCTION ANIMATE_MENU ( item,pull_down : Tree_Index ) : Tree_Index;
  87.    VAR x,y,w,h     : INTEGER;
  88.        dummy       : BOOLEAN;
  89.        sel,old_sel : Tree_Index;
  90.    BEGIN
  91.       Obj_SetState(new_desk_ptr,item,Selected,TRUE);
  92.       Obj_Size(new_desk_ptr,pull_down,x,y,w,h);
  93.       x := x-1;
  94.       y := y-1;
  95.       w := w+2;
  96.       h := h+2;
  97.       Hide_Mouse;
  98.       Blit(screen_mfdb,mem_mfdb,x,y,x,y,w,h);
  99.       unhide(pull_down);
  100.       Obj_Draw(new_desk_ptr,pull_down,Max_Depth,x,y,w,h);
  101.       Show_Mouse;
  102.       sel := Null_Index;
  103.       old_sel := sel;
  104.       Graf_MKState(mx,my,btn_state,kbd_state);
  105.       WHILE btn_state & 1 <> 0 DO BEGIN
  106.          dummy := Obj_Find(new_desk_ptr,pull_down,Max_Depth,mx,my,sel);
  107.          IF sel <> old_sel THEN BEGIN
  108.             IF old_sel <> Null_Index THEN
  109.                Obj_SetState(new_desk_ptr,old_sel,Normal,TRUE);
  110.             IF sel <> Null_Index THEN
  111.                Obj_SetState(new_desk_ptr,sel,Selected,TRUE);
  112.             old_sel := sel
  113.          END;
  114.          Graf_MKState(mx,my,btn_state,kbd_state)
  115.       END;
  116.       IF sel <> Null_Index THEN
  117.          Obj_SetState(new_desk_ptr,sel,Normal,FALSE);
  118.       hide;
  119.       Hide_Mouse;
  120.       Blit(mem_mfdb,screen_mfdb,x,y,x,y,w,h);
  121.       Show_Mouse;
  122.       Obj_SetState(new_desk_ptr,item,Normal,TRUE);
  123.       animate_menu := sel
  124.    END; { ANIMATE_MENU }
  125.  
  126.   FUNCTION IN_EDIT_AREA ( x,y : INTEGER ) : BOOLEAN;
  127.      BEGIN
  128.         IF (x >= area_x) AND (y > area_y) AND (y < area_y+area_h) THEN
  129.            in_edit_area := TRUE
  130.         ELSE
  131.            in_edit_area := FALSE
  132.      END; { IN_EDIT_AREA }
  133.  
  134.   PROCEDURE DECODE_POS ( x,y : INTEGER );
  135.      VAR char_pos,col,line_c : INTEGER;
  136.      BEGIN
  137.         col := (x-edit_x) DIV 8 + 1;
  138.         IF col < 1 THEN
  139.            col := 1
  140.         ELSE IF col > line_length THEN
  141.            col := line_length;
  142.         line_c := (y-(area_y-1)) DIV y_dis;
  143.         IF line_c < 0 THEN
  144.            line_c := 0
  145.         ELSE IF line_c > char_count DIV line_length THEN
  146.            line_c := line_count;
  147.         char_pos := line_c*line_length+col;
  148.         IF char_pos > char_count THEN BEGIN
  149.            char_pos := char_count+1;
  150.            col := char_pos-line_c*line_length
  151.         END;
  152.         Hide_Mouse;
  153.         IF pos_in_str = char_count+1 THEN
  154.            Draw_String(x_pix,y_pix,' ')
  155.         ELSE
  156.            Draw_String(x_pix,y_pix,str[pos_in_str]);
  157.         Show_Mouse;
  158.         column := col;
  159.         line_count := line_c;
  160.         pos_in_str := char_pos
  161.      END; { DECODE_POS }
  162.      
  163.   PROCEDURE CURSOR_LEFT;
  164.      BEGIN
  165.          IF pos_in_str > 1 THEN BEGIN
  166.             Hide_Mouse;
  167.             IF pos_in_str = char_count+1 THEN
  168.                Draw_String(x_pix,y_pix,' ')
  169.             ELSE
  170.                Draw_String(x_pix,y_pix,str[pos_in_str]);
  171.             IF (column = 1) AND (line_count > 0) THEN BEGIN
  172.                column := line_length;
  173.                line_count := line_count-1;
  174.                pos_in_str := pos_in_str-1
  175.             END
  176.             ELSE IF column > 1 THEN BEGIN
  177.                column := column-1;
  178.                pos_in_str := pos_in_str-1
  179.             END;
  180.             Show_Mouse
  181.          END
  182.     END; (* CURSOR_LEFT *)
  183.   PROCEDURE CURSOR_RIGHT;
  184.      BEGIN
  185.          Hide_Mouse;
  186.          Draw_String(x_pix,y_pix,str[pos_in_str]); (* get rid of    *)
  187.          Show_Mouse;                               (* inverse video *)
  188.          column := column+1;
  189.          pos_in_str := pos_in_str+1
  190.     END; (* CURSOR_RIGHT *)
  191.   PROCEDURE INSERT_CHAR;
  192.      VAR i,col,l_c : INTEGER;
  193.      BEGIN
  194.          char_count := char_count+1;
  195.          INSERT(CHR(key),str,pos_in_str);
  196.          l_c := line_count;
  197.          col := column;
  198.          Hide_Mouse;
  199.          FOR i := pos_in_str TO char_count DO BEGIN
  200.              IF col > line_length THEN BEGIN
  201.                 col := 1;
  202.                 l_c := l_c+1
  203.              END;
  204.              x_pix := edit_x+8*(col-1);
  205.              y_pix := edit_y+l_c*y_dis;
  206.              Draw_String(x_pix,y_pix,str[i]);
  207.              col := col+1
  208.          END; (* FOR i *)
  209.          Show_Mouse;
  210.          column := column+1;
  211.          pos_in_str := pos_in_str+1
  212.      END; (* INSERT_CHAR *)
  213.   PROCEDURE DELETE_CHAR;
  214.      VAR i,col,loop_limit,l_c : INTEGER;
  215.      BEGIN
  216.          DELETE(str,pos_in_str,1);
  217.          l_c := line_count;
  218.          col := column;
  219.          char_count := char_count-1;
  220.          { now redraw the remaining portion of the screen, starting with the
  221.            position of the deleted character }
  222.          loop_limit := char_count+1;
  223.          Hide_Mouse;
  224.          FOR i := pos_in_str TO loop_limit DO BEGIN
  225.              IF col > line_length THEN BEGIN
  226.                 col := 1;
  227.                 l_c := l_c+1
  228.              END;
  229.              x_pix := edit_x+8*(col-1);
  230.              y_pix := edit_y+y_dis*l_c;
  231.              IF i = loop_limit THEN
  232.                 Draw_String(x_pix,y_pix,' ')
  233.              ELSE
  234.                 Draw_String(x_pix,y_pix,str[i]);
  235.              col := col+1
  236.          END; (* FOR i *)
  237.          Show_Mouse
  238.     END; (* DELETE_CHAR *)
  239.   PROCEDURE BACKSPACE;
  240.      { caller must check if cursor is not in first position }
  241.      BEGIN
  242.          (* if backspacing from end of line, remove cursor *)
  243.          IF pos_in_str = char_count+1 THEN BEGIN
  244.             Hide_Mouse;
  245.             Draw_String(x_pix,y_pix,' ');
  246.             Show_Mouse
  247.          END;
  248.          column := column-1;            { move to last character }
  249.          pos_in_str := pos_in_str-1;
  250.          IF column = 0 THEN BEGIN
  251.             column := line_length;
  252.             line_count := line_count-1
  253.          END;
  254.          delete_char
  255.      END; (* BACKSPACE *)
  256.   PROCEDURE RESET_PARMS;
  257.      { called when ESC is pressed; also when invalid number is entered }
  258.      BEGIN
  259.          default_draw_attributes;
  260.          Text_Alignment(VDI_Left,0); { standard Draw_String values }
  261.          Set_Clip(0,0,screen_width,screen_height);
  262.          char_count := 0;
  263.          line_count := 0;
  264.          pos_in_str := 1;
  265.          column := 1;
  266.          str := '';
  267.          Hide_Mouse;
  268.          Paint_Rect(area_x,area_y,area_w,area_h);
  269.          Show_Mouse
  270.      END; { RESET_PARMS }
  271.   PROCEDURE CHECK_VALIDITY;
  272.      VAR result : StatusType;
  273.          ptr    : CellPtr;
  274.      BEGIN
  275.         { no INTs in this application!
  276.         IF str_type = AnInteger THEN
  277.            IF (str = '+') OR (str = '-') OR (LENGTH(str) = 0) THEN
  278.               GOTO 5;
  279.         }
  280.         str_pos := 1;
  281.         IF str_type = FloatingPoint THEN
  282.            IF str = '' THEN
  283.               null_input := TRUE
  284.            ELSE BEGIN
  285.               result := valid_number(str);
  286.               IF result <> OK THEN BEGIN
  287.                  alert := Do_Alert('[3][Error in number!][  OK  ]',1);
  288.                  ptr := locate_cell(data_row,data_col);
  289.                  IF ptr <> NIL THEN
  290.                     ptr^.status := result;
  291.                  IF small_text THEN
  292.                     Set_Char_Height(6);
  293.                  cell_on_screen(1,data_row,data_col,TRUE);
  294.                  IF small_text THEN
  295.                     Set_Char_Height(13);
  296.                  write_cell_name;
  297.                  reset_parms;
  298.                  GOTO 5
  299.               END
  300.            END
  301.         ELSE IF (LENGTH(str) = 0) OR (old_form = str) THEN
  302.            null_input := TRUE;
  303.      END; { CHECK_VALIDITY }
  304.  
  305. FUNCTION EXIT_KEY : BOOLEAN;
  306.    BEGIN
  307.        exit_key := TRUE;
  308.        IF (inp_code <> w_Message) AND (inp_code <> w_mouse) THEN
  309.              CASE key OF
  310.                 $011B : BEGIN { ESC }
  311.                    reset_parms;
  312.                    GOTO 5
  313.                 END;
  314.                 $4D00 : inp_code := w_RIGHT_ARROW;
  315.                 $5000 : inp_code := w_DOWN_ARROW;
  316.                 $4800 : inp_code := w_UP_ARROW;
  317.                 $4B00 : inp_code := w_LEFT_ARROW;
  318.                 $1C0D,$720D : inp_code := w_RETURN;
  319.                 $4D36 : inp_code := w_PAGE_RIGHT;
  320.                 $5032 : inp_code := w_PAGE_DOWN;
  321.                 $4838 : inp_code := w_PAGE_UP;
  322.                 $4B34 : inp_code := w_PAGE_LEFT;
  323.                 $1E01 : inp_code := w_CNTL_A;
  324.                 $2C1A : inp_code := w_CNTL_Z;
  325.                 $1414 : inp_code := w_CNTL_T;
  326.                 $3002 : inp_code := w_CNTL_B;
  327.                 $3B00 : inp_code := w_F1;
  328.                 $3C00 : inp_code := w_F2; 
  329.                 $5500 : inp_code := w_sF2;
  330.                 $3D00 : inp_code := w_F3;
  331.                 $5600 : inp_code := w_sF3;
  332.                 $3E00 : inp_code := w_F4;
  333.                 $3F00 : inp_code := w_F5;
  334.                 $4200 : inp_code := w_F8;
  335.                 $4300 : inp_code := w_F9;
  336.                 $4400 : inp_code := w_F10;
  337.                 $1100 : inp_code := w_COLUMN;
  338.                 $2400 : inp_code := w_JUSTIFY;
  339.                 $1900 : inp_code := w_PRECISION;
  340.                 $1E00 : inp_code := w_START_BLOCK;
  341.                 $2C00 : inp_code := w_END_BLOCK;
  342.                 $2000 : inp_code := w_DESELECT;
  343.                 $1300 : inp_code := w_REPLICATE;
  344.                 $1F00 : inp_code := w_SORT;
  345.                 $2200 : inp_code := w_GOTO;
  346.                 $4700 : inp_code := w_HOME;
  347.                 $2F00 : inp_code := w_VIEW;
  348.                 $1800 : inp_code := w_percent;
  349.                 $1500 : inp_code := w_style;
  350.                 $7800 : inp_code := alt_1;
  351.                 $7900 : inp_code := alt_2;
  352.                 $7A00 : inp_code := alt_3;
  353.                 $7B00 : inp_code := alt_4;
  354.                 $3000 : inp_code := alt_b;
  355.                 $3200 : inp_code := alt_m;
  356.                 $2100 : inp_code := alt_f;
  357.                 $2600 : inp_code := alt_l;
  358.                 $1400 : inp_code := alt_t;
  359.                 $2106 : inp_code := c_f;
  360.                 $260C : inp_code := c_l;
  361.                 $2300 : inp_code := alt_h; 
  362.                 $1700 : inp_code := alt_i;
  363.                 $4000 : inp_code := f6;
  364.                 $4100 : inp_code := f7;
  365.                 $5900 : inp_code := sf6;
  366.                 $5A00 : inp_code := sf7;
  367.                 $2E00 : inp_code := alt_c;
  368.                 $2D00 : inp_code := alt_x;
  369.                 $2500 : inp_code := alt_k;
  370.                 $0211 : inp_code := c_1;
  371.                 $0300 : inp_code := c_2;
  372.                 $0413 : inp_code := c_3;
  373.                 $0514 : inp_code := c_4;
  374.                 OTHERWISE : exit_key := FALSE
  375.              END { CASE }   
  376.        ELSE
  377.           exit_key := FALSE  
  378.    END; { EXIT_KEY }
  379.  
  380. PROCEDURE INITIALIZE;
  381.    BEGIN
  382.       y_dis := 16 DIV rez;
  383.       default_draw_attributes;
  384.       Set_Clip(0,0,screen_width,screen_height);
  385.       Text_Alignment(VDI_Left,0); { standard Draw_String values }
  386.       char_count := 0;
  387.       pos_in_str := 1;
  388.       column := 1;
  389.       line_count := 0;
  390.       Hide_Mouse;
  391.       Paint_Rect(area_x,area_y,area_w,area_h);
  392.       IF inp_code <> w_F THEN BEGIN
  393.          old_form := '';
  394.          str := ''
  395.       END
  396.       ELSE BEGIN { a formula or label was passed and should be displayed }
  397.          old_form := str;
  398.          char_count := LENGTH(str);
  399.          IF LENGTH(str) >= line_length THEN BEGIN
  400.             temp_1 := COPY(str,1,line_length);
  401.             Draw_String(edit_x,edit_y,temp_1);
  402.             line_count := 1;
  403.             IF LENGTH(str) > line_length THEN BEGIN
  404.                temp_1 := COPY(str,line_length+1,LENGTH(str)-line_length);
  405.                Draw_String(edit_x,edit_y+y_dis,temp_1);
  406.                column := LENGTH(temp_1)+1
  407.             END
  408.             ELSE
  409.                column := 1
  410.          END
  411.          ELSE BEGIN
  412.             Draw_String(edit_x,edit_y,str);
  413.             column := char_count+1
  414.          END;
  415.          pos_in_str := char_count+1
  416.       END;
  417.       Show_Mouse
  418.    END; { INITIALIZE }
  419.  
  420. PROCEDURE PREPARE_FOR_NEXT_INPUT;
  421.    BEGIN
  422.       IF column > line_length THEN BEGIN
  423.          column := 1;
  424.          line_count := line_count+1
  425.       END;
  426.       x_pix := edit_x+8*(column-1); (* Get next character pos *)
  427.       y_pix := edit_y+line_count*16 DIV rez;
  428.       (* This prevents 'blinking' of characters if a cursor key or
  429.          backspace is pressed repeatedly when the cursor can not
  430.          advance ( i.e. pressing backspace when the cursor is on the
  431.          first character ). Can NOT be replaced with XOR_Mode *)
  432.       Hide_Mouse;
  433.       Draw_String(x_pix,y_pix,' ');
  434.       Draw_Mode(Rev_Trans_Mode);
  435.       IF pos_in_str <= char_count THEN
  436.          Draw_String(x_pix,y_pix,str[pos_in_str])
  437.       ELSE
  438.          Draw_String(x_pix,y_pix,' ');
  439.       Draw_Mode(Replace_Mode);
  440.       Show_Mouse
  441.    END; { PREPARE_FOR_NEXT_INPUT }
  442.        
  443. PROCEDURE META_INSERT;
  444.    VAR i : INTEGER;
  445.    BEGIN
  446.       IF (pos_in_str > max_length) OR 
  447.          (LENGTH(str)+LENGTH(temp_1) > max_length) THEN BEGIN
  448.          alert := Do_Alert(too_long,1);
  449.          IF pos_in_str > max_length THEN BEGIN
  450.             Hide_Mouse;
  451.             Draw_String(x_pix,y_pix,' ');
  452.             Show_Mouse
  453.          END;   
  454.          GOTO 100
  455.       END;
  456.       i := 1;
  457.       IF pos_in_str <= char_count THEN { insert }
  458.          WHILE i <= LENGTH(temp_1) DO BEGIN
  459.             key := ORD(temp_1[i]);
  460.             insert_char; { insert mode }
  461.             i := i+1;
  462.             IF i <= LENGTH(temp_1) THEN
  463.                prepare_for_next_input
  464.          END
  465.       ELSE 
  466.       WHILE i <= LENGTH(temp_1) DO BEGIN
  467.          str := CONCAT(str,temp_1[i]);
  468.          Hide_Mouse;
  469.          Draw_String(x_pix,y_pix,temp_1[i]);
  470.          Show_Mouse;
  471.          char_count := char_count+1;
  472.          pos_in_str := pos_in_str+1;
  473.          column := column+1;
  474.          i := i+1;
  475.          IF i <= LENGTH(temp_1) THEN
  476.             prepare_for_next_input
  477.       END
  478.    END; { META_INSERT }   
  479.                        
  480.   BEGIN  (* WINDOW_INPUT *)
  481.         quit := FALSE;
  482.         IF small_text THEN
  483.            Set_Char_Height(13);
  484.         IF Front_Window = act_hdl THEN
  485.            initialize;
  486.  5:     null_input := FALSE;
  487.         inp_code := NoCode;
  488.         LOOP (* Main Loop - get keyboard, message, and mouse button events *)
  489.            IF Front_Window = act_hdl THEN BEGIN
  490.               bad_str := FALSE;
  491.               prepare_for_next_input
  492.            END;
  493.            End_Update;
  494.            IF Front_Window = act_hdl THEN
  495.               event := Get_Event ( inp_mask ,
  496.                                    1 , 1 , 1 , 0 ,
  497.                                    FALSE , 0 , 0 , 0 , 0 ,
  498.                                    FALSE , 0 , 0 , 0 , 0 ,
  499.                                    msg_area ,
  500.                                    key, btn_state, b_cnt, mx, my, kbd_state )
  501.            ELSE
  502.               event := Get_Event(E_Message,0,0,0,0,FALSE,0,0,0,0,
  503.                                  FALSE,0,0,0,0,msg_area,dummy,dummy,
  504.                                  dummy,dummy,dummy,dummy);
  505.            Begin_Update;
  506.            IF event & E_Message <> 0 THEN BEGIN
  507.               IF (msg_area[0] = MN_Selected) AND
  508.                  (msg_area[3] = mhelp) THEN BEGIN
  509.                  CASE msg_area[4] OF
  510.                     mkeyboar : help(1);
  511.                     mformula : help(2);
  512.                     mprinth  : help(3);
  513.                     mmouse   : help(4);
  514.                     mcellref : help(5);
  515.                     mrecalcm : help(6)
  516.                  END;
  517.                  Menu_Normal(main_menu,mhelp);
  518.                  GOTO 100
  519.               END;
  520.               inp_code := w_MESSAGE;
  521.               quit := TRUE
  522.            END
  523.            ELSE IF event & E_Button <> 0 THEN
  524.               IF kbd_state & 3 = 0 THEN { neither shift key pressed }
  525.                  IF Obj_Find(new_desk_ptr,menubox,Max_Depth,
  526.                              mx,my,indx) THEN
  527.                     IF str_type = AlphaNumeric THEN BEGIN
  528.                        ins := TRUE;
  529.                        CASE indx OF
  530.                           pullmath : BEGIN
  531.                              indx := animate_menu(pullmath,mathmenu);
  532.                              CASE indx OF
  533.                                 pullln    : temp_1 := 'LN(';
  534.                                 pullexp   : temp_1 := 'EXP(';
  535.                                 pulllog   : temp_1 := 'LOG(';
  536.                                 pullsqr   : temp_1 := 'SQR(';
  537.                                 pullsqrt  : temp_1 := 'SQRT(';
  538.                                 pullfac   : temp_1 := 'FAC(';
  539.                                 pulldiv   : temp_1 := 'DIV(';
  540.                                 pullmod   : temp_1 := 'MOD(';
  541.                                 pullroun  : temp_1 := 'ROUND(';
  542.                                 pulltrnc  : temp_1 := 'TRUNC(';
  543.                                 pullabs   : temp_1 := 'ABS(';
  544.                                 pullrand  : temp_1 := 'RAND(';
  545.                                 pullplus  : temp_1 := '+';
  546.                                 pullminu  : temp_1 := '-';
  547.                                 pullstar  : temp_1 := '*';
  548.                                 pullslas  : temp_1 := '/';
  549.                                 pullcara  : temp_1 := '^';
  550.                                 pullopen  : temp_1 := '(';
  551.                                 pullclos  : temp_1 := ')';
  552.                                 pullcoln  : temp_1 := ':';
  553.                                 pullcomm  : temp_1 := ',';
  554.                                 OTHERWISE : ins := FALSE
  555.                              END
  556.                           END;   
  557.                           pulltrig : BEGIN
  558.                              indx := animate_menu(pulltrig,trigmenu);
  559.                              CASE indx OF
  560.                                 pullsin   : temp_1 := 'SIN(';
  561.                                 pullcos   : temp_1 := 'COS(';
  562.                                 pulltan   : temp_1 := 'TAN(';
  563.                                 pullasin  : temp_1 := 'ASIN(';
  564.                                 pullacos  : temp_1 := 'ACOS(';
  565.                                 pullatan  : temp_1 := 'ATAN(';
  566.                                 pullrad   : temp_1 := 'RAD(';
  567.                                 pulldeg   : temp_1 := 'DEG(';
  568.                                 pullpi    : temp_1 := 'PI()';
  569.                                 OTHERWISE : ins := FALSE
  570.                              END
  571.                           END;
  572.                           pullstat : BEGIN
  573.                              indx := animate_menu(pullstat,statmenu);
  574.                              CASE indx OF
  575.                                 pullsum   : temp_1 := 'SUM(';
  576.                                 pullprod  : temp_1 := 'PROD(';
  577.                                 pullmean  : temp_1 := 'MEAN(';
  578.                                 pullvar   : temp_1 := 'VAR(';
  579.                                 pullsdev  : temp_1 := 'SDEV(';
  580.                                 pullserr  : temp_1 := 'SERR(';
  581.                                 pulllinr  : temp_1 := 'LINR(';
  582.                                 pullcorr  : temp_1 := 'CORR(';
  583.                                 pullpred  : temp_1 := 'PREDV(';
  584.                                 pullmax   : temp_1 := 'MAX(';
  585.                                 pullmin   : temp_1 := 'MIN(';
  586.                                 pullcoun  : temp_1 := 'COUNT(';
  587.                                 OTHERWISE : ins := FALSE
  588.                              END
  589.                           END;
  590.                           pullfin : BEGIN
  591.                              indx := animate_menu(pullfin,finmenu);
  592.                              CASE indx OF
  593.                                 pullpv    : temp_1 := 'PV(';
  594.                                 pullfv    : temp_1 := 'FV(';
  595.                                 pullnper  : temp_1 := 'NPER(';
  596.                                 pullpmt   : temp_1 := 'PMT(';
  597.                                 OTHERWISE : ins := FALSE
  598.                              END
  599.                           END;
  600.                           pullbool : BEGIN
  601.                              indx := animate_menu(pullbool,boolmenu);
  602.                              CASE indx OF
  603.                                 pullif    : temp_1 := 'IF(';
  604.                                 pulland   : temp_1 := 'AND(';
  605.                                 pullor    : temp_1 := 'OR(';
  606.                                 pullnot   : temp_1 := 'NOT(';
  607.                                 pulleq    : temp_1 := '=';
  608.                                 pullneq   : temp_1 := '<>';
  609.                                 pulllt    : temp_1 := '<';
  610.                                 pulllteq  : temp_1 := '<=';
  611.                                 pullgt    : temp_1 := '>';
  612.                                 pullgteq  : temp_1 := '>=';
  613.                                 OTHERWISE : ins := FALSE
  614.                              END
  615.                           END;   
  616.                           pulltab : BEGIN
  617.                              indx := animate_menu(pulltab,tabmenu);
  618.                              CASE indx OF
  619.                                 pullindx  : temp_1 := 'INDEX(';
  620.                                 pullvl    : temp_1 := 'VLOOKUP(';
  621.                                 pullhl    : temp_1 := 'HLOOKUP(';
  622.                                 OTHERWISE : ins := FALSE
  623.                              END
  624.                           END;
  625.                           OTHERWISE : ins := FALSE
  626.                        END;
  627.                        IF ins THEN 
  628.                           meta_insert;
  629.                        GOTO 100
  630.                     END
  631.                     ELSE
  632.                        GOTO 100
  633.                  ELSE IF Obj_Find(new_desk_ptr,cross,Max_Depth,
  634.                              mx,my,indx) THEN BEGIN
  635.                     delete_cell(data_row,data_col,FALSE);
  636.                     IF small_text THEN
  637.                        Set_Char_Height(6);
  638.                     cell_on_screen(Black,data_row,data_col,TRUE);
  639.                     IF small_text THEN
  640.                        Set_Char_Height(13);
  641.                     key := 0;
  642.                     inp_code := NoCode;
  643.                     quit := TRUE
  644.                  END
  645.                  ELSE IF Obj_Find(new_desk_ptr,check,Max_Depth,
  646.                                   mx,my,indx) THEN
  647.                     key := $1C0D
  648.                  ELSE IF in_edit_area(mx,my) THEN BEGIN
  649.                     decode_pos(mx,my);
  650.                     GOTO 100
  651.                  END
  652.                  ELSE IF Wind_Find(mx,my) = act_hdl THEN BEGIN
  653.                     { the following allows user to get out of "runaway"
  654.                       keypresses by clicking on cell; we must clear
  655.                       AES message pipe-line of keyboard events. The
  656.                       pipe can hold about 8 events and the keyboard
  657.                       buffer holds more than this; however, as event slots
  658.                       become open, the AES fills them and the timer clause
  659.                       assures I get all of the keys in the keyboard buffer }
  660.                     REPEAT
  661.                        event := Get_Event(E_KeyBoard|E_Timer,0,0,0,2,
  662.                                           FALSE,0,0,0,0,FALSE,0,0,0,0,
  663.                                           msg_area,dummy,dummy,dummy,
  664.                                           dummy,dummy,dummy)
  665.                     UNTIL event & E_Timer <> 0;                      
  666.                     inp_code := w_MOUSE;
  667.                     msg_area[0] := b_cnt;
  668.                     msg_area[1] := mx;
  669.                     msg_area[2] := my;
  670.                     quit := TRUE
  671.                  END
  672.                  ELSE
  673.                     GOTO 100
  674.               ELSE IF mouse_row_col(mx,my,my,mx) THEN
  675.                  IF str_type = AlphaNumeric THEN BEGIN
  676.                     int_to_string(my,temp_1);
  677.                     temp_1 := CONCAT(col_name[mx],temp_1);
  678.                     meta_insert;
  679.                     event := Get_Event(E_Timer,0,0,0,200,FALSE,0,0,0,0,
  680.                                        FALSE,0,0,0,0,msg_area,dummy,dummy,
  681.                                        dummy,dummy,dummy,dummy);
  682.                     GOTO 100                 
  683.                  END
  684.                  ELSE 
  685.                     GOTO 100
  686.               ELSE
  687.                  GOTO 100;
  688.            { must have been an E_KeyBoard }
  689.            EXIT IF (exit_key) OR (quit);
  690.            IF Front_Window = act_hdl THEN BEGIN
  691.               IF (key = $7300) AND (char_count > 0) THEN
  692.                  cursor_left
  693.               ELSE IF (key = $7400) AND 
  694.                       (column+line_count*line_length <= char_count) THEN
  695.                  cursor_right
  696.               ELSE IF (key = $537F) AND (pos_in_str <= char_count) THEN
  697.                  delete_char
  698.               ELSE IF (key = $0E08) AND (pos_in_str <= char_count+1) AND
  699.                       (pos_in_str > 1) THEN
  700.                  backspace
  701.               ELSE BEGIN
  702.                  key := key & $00FF; (* convert to ASCII *)
  703.                  IF (pos_in_str > max_length) THEN BEGIN
  704.                     alert := Do_Alert(too_long,1);
  705.                     Hide_Mouse;
  706.                     Draw_String(x_pix,y_pix,' ');
  707.                     Show_Mouse;
  708.                     GOTO 100
  709.                  END;
  710.                  { No INTs in this app! Should pass or delare a set 'digits'
  711.                    to use i.e. ['1'..'9','+','-']
  712.                  IF (str_type = AnInteger) THEN BEGIN
  713.                     IF NOT (CHR(key) IN digits) THEN 
  714.                        bad_str := TRUE;
  715.                     IF (pos_in_str > 1) AND ((key = $2B) OR (key = $2D)) THEN
  716.                        bad_str := TRUE
  717.                  END;
  718.                  }
  719.                  IF (str_type = FloatingPoint) THEN
  720.                     IF NOT (CHR(key) IN float) THEN
  721.                        bad_str := TRUE;
  722.                  IF (str_type = AlphaNumeric) THEN
  723.                     IF NOT ((key >= $20) AND (key <= $7E)) THEN
  724.                        bad_str := TRUE;
  725.                  IF NOT bad_str THEN
  726.                     (* Here, the character retrieved is added
  727.                        or inserted to str. *)
  728.                     IF pos_in_str <= char_count THEN { insert }
  729.                        IF char_count = max_length THEN
  730.                           alert := Do_Alert(too_long,1)
  731.                        ELSE
  732.                           insert_char { insert mode }
  733.                     ELSE BEGIN
  734.                        str := CONCAT(str,CHR(key));
  735.                        Hide_Mouse;
  736.                        Draw_String(x_pix,y_pix,CHR(key));
  737.                        Show_Mouse;
  738.                        char_count := char_count+1;
  739.                        pos_in_str := pos_in_str+1;
  740.                        column := column+1
  741.                     END
  742.               END (* ELSE *)
  743.            END; { IF Front_Window = act_hdl }
  744. 100:    END; (* LOOP *)
  745.         IF small_text THEN
  746.            Set_Char_Height(6);
  747.         IF Front_Window = act_hdl THEN
  748.            IF inp_code <= w_return THEN { everything that can assign }
  749.               check_validity
  750.   END; (* WINDOW_INPUT *)
  751.  
  752. BEGIN  (* dummy program for modular compilation *)
  753. END.
  754.  
  755.  
  756.