home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume35 / ss / part09 < prev    next >
Encoding:
Text File  |  1993-03-02  |  60.0 KB  |  2,144 lines

  1. Newsgroups: comp.sources.misc
  2. From: art@cs.ualberta.ca (Art Mulder)
  3. Subject: v35i095:  ss - Simple Spreadsheet program, v1.2b, Part09/11
  4. Message-ID: <1993Feb22.154115.22000@sparky.imd.sterling.com>
  5. X-Md4-Signature: d2c20e4200f6426ad0f7b3e8b7571b01
  6. Date: Mon, 22 Feb 1993 15:41:15 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: art@cs.ualberta.ca (Art Mulder)
  10. Posting-number: Volume 35, Issue 95
  11. Archive-name: ss/part09
  12. Environment: curses, sunos, sysv, ultrix, sgi, dec, mips, sun
  13.  
  14. #! /bin/sh
  15. # This is a shell archive.  Remove anything before this line, then feed it
  16. # into a shell via "sh file" or similar.  To overwrite existing files,
  17. # type "sh file -c".
  18. # Contents:  ss_12b/ctrl.c ss_12b/disprange.c ss_12b/examples/borrow.ss
  19. #   ss_12b/examples/payments.ss ss_12b/help.c ss_12b/menu_cell.c
  20. #   ss_12b/range.c ss_12b/sunfkeys/f1.c ss_12b/vmtbl.c
  21. # Wrapped by kent@sparky on Sat Feb 20 16:01:04 1993
  22. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  23. echo If this archive is complete, you will see the following message:
  24. echo '          "shar: End of archive 9 (of 11)."'
  25. if test -f 'ss_12b/ctrl.c' -a "${1}" != "-c" ; then 
  26.   echo shar: Will not clobber existing file \"'ss_12b/ctrl.c'\"
  27. else
  28.   echo shar: Extracting \"'ss_12b/ctrl.c'\" \(12902 characters\)
  29.   sed "s/^X//" >'ss_12b/ctrl.c' <<'END_OF_FILE'
  30. X/**********************************************************************
  31. X* %M%
  32. X* ss     :    A SpreadSheet Program
  33. X*
  34. X* Art's Spreadsheet program.          Art Mulder ( art@cs.ualberta.ca )
  35. X* University of Alberta, Department of Computing Science.
  36. X***********************************************************************
  37. X* Process Control Character Commands (NOT menu options)
  38. X**********************************************************************/
  39. X#ifndef lint
  40. X  static char Sccsid[] = "%W% %G%";
  41. X#endif
  42. X
  43. X/*
  44. X * Include files
  45. X */
  46. X#include <stdio.h>
  47. X#include <sys/types.h>
  48. X#include <signal.h>
  49. X#include "curses_stuff.h"
  50. X#include <ctype.h>
  51. X
  52. X#include "ss.h"
  53. X#include "keys.h"
  54. X
  55. X#include "disprange.h"
  56. X#include "ctrl.h"
  57. X#include "menu_cell.h"
  58. X#include "menu_misc.h"
  59. X
  60. X/*    Local Macro Definitions
  61. X *----------------------------------------------------------------------
  62. X */
  63. X
  64. X/* 
  65. X * Move the cursor to the HOME position (Cell A0) in the Spreadsheet. 
  66. X */
  67. X#define doHOME    { currow = 0; curcol = 0; FullUpdate++; Message("<Home>"); }
  68. X
  69. X/*
  70. X * Jump to the Last Valid Row in the current column.
  71. X */
  72. X#define doEND     {                         \
  73. X    register struct ent *p;                    \
  74. X    currow = maxrows - 1;                    \
  75. X    while (!VALID_CELL(p, currow, curcol) && currow > 0)    \
  76. X        currow--;                        \
  77. X    Message("<End>");                    \
  78. X    }
  79. X
  80. X#define doSCROLL_LEFT     backcol((curcol-stcol+1)+1)
  81. X#define doSCROLL_RIGHT    forwcol(lcols -(curcol-stcol)+1)
  82. X
  83. X/*    Function Prototypes  (Local Functions)
  84. X *----------------------------------------------------------------------
  85. X */
  86. X
  87. X    void ProcessControls();
  88. X    int ProcessCursors();
  89. X
  90. X    void doForwardCell();
  91. X    void doBackwardCell();
  92. X
  93. X/*    External Global variables
  94. X *----------------------------------------------------------------------
  95. X */
  96. X    extern int running;        /* from main.c */
  97. X    extern int ClearScreen;    /* ditto */
  98. X    extern int showneed;    /* ditto */
  99. X    extern int showexpr;    /* ditto */
  100. X
  101. X    extern int lcols;        /* From screen.c */
  102. X
  103. X
  104. X/*    Local Global variables
  105. X *----------------------------------------------------------------------
  106. X */
  107. X
  108. Xstatic int meta_flag = FALSE;    /* Flag: indicates <ESC> prefix */
  109. Xstatic int ctrlx_flag = FALSE;    /* Flag: indicates ^X prefix */
  110. X
  111. X/*      Externally Accessible Functions
  112. X ***********************************************************************
  113. X */
  114. X
  115. X/************************
  116. X*************************
  117. X** NOTE: This whole setup is a bit (!) of a kludge to allow
  118. X** functins to *just* process cursor commands, and no other forms of
  119. X** input.  Due to the fact that both cell-cursor
  120. X** motion commands, and regular control-key commands make use of
  121. X** the <Esc>- and ^X- prefix's, it becomes difficult to separate the
  122. X** the two operations.
  123. X**
  124. X** Currently, only the function "RangeForceInput()" in "disprange.c"
  125. X** calls the "ProcessCursorCommands()" function.  That function is
  126. X** removable, if/when we move to a CUT/COPY/PASTE ``clipboard'' style
  127. X** of editing the spreadsheet. 
  128. X**
  129. X** When no functions call "ProcessCursorCommands()" any longer,
  130. X** then we can safely take all the functions in this file and
  131. X** merge them into one, clean, comprehensible, function.
  132. X*************************
  133. X************************/
  134. X
  135. Xvoid ProcessControlCommands(c)
  136. X/*----------------------------------------------------------------------
  137. X** Process all Control-Key (& Related) Commands.
  138. X**
  139. X** This function serves as a "front end" to the actual
  140. X** Control-key / Function-key command processor function
  141. X** ``ProcessControls()''.
  142. X** The reason for this front-end is to handle two-key control-key
  143. X** combinations --> the <Esc>- and ^X- prefixed commands.
  144. X*/
  145. X    register int   c;    /* Control character command to process */
  146. X{
  147. X
  148. X    /*
  149. X     * Procedure: Go process/parse the control key command ``c''.
  150. X     * If one of the flag's indicating an <Esc>- or ^X- prefix is then
  151. X     * set to be true, then grab the next character and process it
  152. X     * also.
  153. X     */
  154. X
  155. X    ProcessControls(c);     
  156. X    if ( (meta_flag == TRUE) || (ctrlx_flag == TRUE) ) {
  157. X    if (meta_flag == TRUE)
  158. X        Message("** Meta -");
  159. X    else
  160. X        Message("** Ctrl X - ");
  161. X    
  162. X    c = nmgetch();
  163. X    ProcessControls(c);
  164. X    meta_flag = ctrlx_flag = FALSE;
  165. X    }
  166. X
  167. X} /* ProcessControlCommands() */
  168. X
  169. X
  170. Xint ProcessCursorCommands(c)
  171. X/*----------------------------------------------------------------------
  172. X** Process all Cell-cursor motion commands... ONLY
  173. X**
  174. X** This function serves as a "front end" to the actual
  175. X** Cursor-motion  command processor function ``ProcessCursors()''.
  176. X**
  177. X** This function is derived from "ProcessControlCommands()".
  178. X**
  179. X** RETURNS: TRUE if `c' was in fact a cursor motion,
  180. X**          FALSE otherwise.
  181. X*/
  182. X    register int   c;    /* Control character command to process */
  183. X{
  184. X    int return_val;        /* To be returned... */
  185. X    
  186. X    return_val = ProcessCursors(c);
  187. X    
  188. X    if ( (meta_flag == TRUE) || (ctrlx_flag == TRUE) ) {
  189. X    if (meta_flag == TRUE)
  190. X        Message("** Meta -");
  191. X    else
  192. X        Message("** Ctrl X - ");
  193. X    
  194. X    c = nmgetch();
  195. X    return_val = ProcessCursors(c);
  196. X    meta_flag = ctrlx_flag = FALSE;
  197. X
  198. X    if (return_val != TRUE)    /* INVALID Meta- or ^X- command! */
  199. X        beep();
  200. X    }
  201. X    return return_val;
  202. X    
  203. X} /* ProcessCursorCommands() */
  204. X
  205. X/*      Internal Functions
  206. X ***********************************************************************
  207. X */
  208. X
  209. Xvoid ProcessControls(c)
  210. X/*----------------------------------------------------------------------
  211. X** NOTE: see 'keys.h' for definitions of control characters
  212. X*/
  213. X    register int   c;    /* Control character command to process */
  214. X{
  215. X/* (1)
  216. X * First go see if it is a Cell-Cursor Movement command.  If so,
  217. X * process it in that function.
  218. X */
  219. X    if (ProcessCursors(c) != TRUE) {
  220. X
  221. X/* (2)
  222. X * Else, check ``meta_flag'' to see if we are processing the second
  223. X * character of a Meta (<Esc>-) prefixed command sequence.
  224. X */
  225. X    if (meta_flag == TRUE)
  226. X        switch (c) {
  227. X/**
  228. X ** Currently, only cursor-movement keys use Meta- prefixes
  229. X **/
  230. X          default:
  231. X        Message("** Invalid Meta- command");
  232. X        beep();        /* error bell */
  233. X        break;
  234. X        }
  235. X/* (3)
  236. X * Else, check ``ctrlx_flag'' to see if we are processing the second
  237. X * character of a Control-X prefixed command sequence.
  238. X */
  239. X      else if (ctrlx_flag == TRUE)
  240. X        switch (c) {
  241. X    /*
  242. X     * Menu Shortcuts: Edit Menu.
  243. X     */
  244. X          case kEDVAL:    CellEditValue();    break;
  245. X          case kEDLABL:    CellEditLabel();    break;
  246. X        
  247. X          default:
  248. X        Message("** Invalid Meta- command");
  249. X        beep();        /* error bell */
  250. X        break;
  251. X        } 
  252. X
  253. X    else
  254. X/* (4)
  255. X * Else, it must just be a single Control-Key/Function-Key command.
  256. X */
  257. X        switch (c) {
  258. X
  259. X    /*
  260. X     * General Commands
  261. X     */
  262. X          case kMETA:    meta_flag = TRUE;    break;
  263. X          case kCTRLX:    ctrlx_flag = TRUE;    break;
  264. X        
  265. X          case kTAB:     RangeToggle();        break;
  266. X
  267. X          case ctl('m'):        /* ^M = <Return> */
  268. X          switch(craction) {
  269. X            case CRROWS:
  270. X              if ((rowlimit >= 0) && (currow >= rowlimit)) {
  271. X              forwcol(1);
  272. X              currow = 0;
  273. X              } else {
  274. X              forwrow(1);
  275. X              }
  276. X              break;
  277. X            case CRCOLS:
  278. X              if ((collimit >= 0) && (curcol >= collimit)) {
  279. X              forwrow(1);
  280. X              curcol = 0;
  281. X              } else {
  282. X              forwcol(1);
  283. X              }
  284. X              break;
  285. X            default:
  286. X              break;
  287. X          }
  288. X        break;
  289. X
  290. X          case kBREAK:     running = 0;    break; /* Quit Program */
  291. X
  292. X#ifdef SIGTSTP
  293. X          case kSTOP:    /* Stop process */
  294. X        (void) deraw();
  295. X        (void) kill(0, SIGTSTP); /* Nail process group */
  296. X
  297. X                /* the pc stops here */
  298. X
  299. X        (void) goraw();
  300. X        break;
  301. X#endif
  302. X
  303. X      /*
  304. X       * Menu Shortcuts: Edit Menu.
  305. X       */
  306. X          case DEL: case kBS:    /* <DEL> & <BackSpc>, Erase Cur Cell */
  307. X          case kDEL:
  308. X        /* NOTE: For clean code, may prefer to substitute a call
  309. X         * to EditErase().  With no range defined, it will erase
  310. X         * the current cell.  However it will also prompt for
  311. X         * confirmation.  Perhaps If/When a proper cut/paste/undo
  312. X         * is written in, that be an appropriate fix.
  313. X         */
  314. X        Sprintf(line,"erase [range]");
  315. X        PROCESS_line;
  316. X        break;
  317. X              
  318. X      /*
  319. X       * Menu Shortcuts: Misc Menu.
  320. X       */
  321. X          case kREDRAW: MiscRedraw(FALSE); break;
  322. X          case kVAL:    MiscRedraw(TRUE);  break; /* & hilite Values */
  323. X          case kEXP:    MiscRedraw_Expr(); break; /* & hilite Expr'ns */
  324. X
  325. X      /*
  326. X       * Menu Shortcuts: CellMenu.
  327. X       */
  328. X          case kGOTO:    CellGoto();    break; /* Goto a Cell */
  329. X          case kMARK:    CellMark();    break; /* Mark a Cell */
  330. X          case kCOPY:    CellCopy();    break; /* Copy a Marked Cell */
  331. X    
  332. X      /*
  333. X       * Unknown
  334. X       */
  335. X          default:        /* Unknown */
  336. X        Message ("No such command (^%c)", c + 0100);
  337. X        break;
  338. X        } 
  339. X    } /* end "if (ProcessCursors(c) != TRUE)" */
  340. X
  341. X} /* ProcessControls() */
  342. X
  343. Xint ProcessCursors(c)
  344. X/*----------------------------------------------------------------------
  345. X** Process all Cell-Cursor Movement Commands.
  346. X** - When inputting a range of cells, (ie: for copying a range of cells)
  347. X**   It is desirable to move the cursor around in the spread sheet.
  348. X** - Therefore, seperate all the Cell-Cursor movement commands into
  349. X**   a seperate function, here, so that they can be referenced from
  350. X**   more than one place in the program.
  351. X** RETURNS: TRUE:  If a cursor command was processed.
  352. X**        FALSE: Otherwise.
  353. X** NOTE: see 'keys.h' for definitions of control characters
  354. X**
  355. X** Is this a hack?  We'll see.
  356. X*/
  357. X    register int   c;    /* Control character command to process */
  358. X{
  359. X    static int arg = 1;    /* numeric argument, sc holdover */
  360. X
  361. X
  362. X/* 
  363. X * (1) Check ``meta_flag'' to see if we are processing the second
  364. X * character of a Meta (<Esc>-) prefixed command sequence.
  365. X */
  366. X    if (meta_flag == TRUE)
  367. X    switch (c) {
  368. X
  369. X      case kHOME:     doHOME;             break;
  370. X      case kEND:     doEND;                 break;
  371. X      case kPGUP:     backrow((currow-strow+1)+3);
  372. X        break;        /* (Half-) Page Up */
  373. X      case kBACK:     doBackwardCell();        break;
  374. X      case kFORW:     doForwardCell();         break;
  375. X
  376. X      default:
  377. X        return FALSE;
  378. X        break;
  379. X    }
  380. X/*
  381. X * (2) Else, check ``ctrlx_flag'' to see if we are processing the second
  382. X * character of a Control-X prefixed command sequence.
  383. X */
  384. X    else if (ctrlx_flag == TRUE)
  385. X    switch (c) {
  386. X      case kPGLEFT:    doSCROLL_LEFT;  break; /* Scroll Half-page left */
  387. X      case kPGRIGHT:   doSCROLL_RIGHT; break; /* Scroll Half-page right */
  388. X
  389. X      default:
  390. X        return FALSE;
  391. X        break;
  392. X    } 
  393. X
  394. X    else
  395. X/* 
  396. X * (3) Else, it must just be a single Control-Key/Function-Key command.
  397. X */
  398. X    switch (c) {
  399. X
  400. X    /*
  401. X     * CURSOR KEYS:  Move the Cell Cursor 1 Cell in different directions
  402. X     */
  403. X      case kLEFT:    backcol(arg);    break;
  404. X      case kRIGHT: forwcol(arg);
  405. X#ifdef RIGHT_CBUG
  406. X        wasforw++;
  407. X#endif
  408. X        break;
  409. X      case kDOWN:    forwrow(arg);    break;
  410. X      case kUP:    backrow(arg);    break;
  411. X
  412. X    /*
  413. X     * CURSOR MOVEMENT:    Moves the Cell Cursor...
  414. X     */
  415. X      case kJUMP:        /* to the end of a range */
  416. X        Message("(** Jump to the End of a range)");
  417. X        Prompt("Choose Direction to jump in, or <CR> to abort :");
  418. X
  419. X        switch (nmgetch()) {
  420. X          case kUP:     doend(-1, 0); break;
  421. X          case kDOWN:     doend( 1, 0); break;
  422. X          case kLEFT:      doend( 0,-1); break;
  423. X          case kRIGHT:     doend( 0, 1); break;
  424. X
  425. X          case kABORT:        /* Abort current command */
  426. X          case ' ':
  427. X        ClearMessage;
  428. X        /** Refresh(); Jan 25/93 **/
  429. X        break;
  430. X          default:
  431. X        Message("** Invalid Jump command");
  432. X        beep();        /* error bell */
  433. X        break;
  434. X        }
  435. X        break;
  436. X
  437. X      case kTOP:    currow = 0; break; /* to Top row in cur. col. */
  438. X
  439. X      case kSTART:  curcol = 0; break; /* to col. 0 in cur. row */
  440. X      case kFINISH:        /* Jump to End of current row */
  441. X        {
  442. X        register struct ent *p;
  443. X
  444. X        curcol = maxcols - 1;
  445. X        while (!VALID_CELL(p, currow, curcol) && curcol > 0)
  446. X            curcol--;
  447. X        break;
  448. X        }
  449. X
  450. X      case kPGDN:    /* (Half-) Page Down */
  451. X        forwrow(LINES-RESROW-(currow-strow)+1);
  452. X        break;
  453. X
  454. X      default:        /* not a cursor movement command */
  455. X        return(FALSE);
  456. X    } /* switch */
  457. X
  458. X    return(TRUE);
  459. X
  460. X} /* ProcessCursors() */
  461. X
  462. Xvoid doForwardCell()
  463. X/*----------------------------------------------------------------------
  464. X** - Forward to next valid cell
  465. X*/
  466. X{
  467. X    register struct ent *p;
  468. X
  469. X    do {
  470. X        if (curcol < maxcols - 1)
  471. X            curcol++;
  472. X    else {
  473. X        if (currow < maxrows - 1) {
  474. X            while(++currow < maxrows - 1 && row_hidden[currow])
  475. X            /* NULL BODY */;
  476. X            curcol = 0;
  477. X            } else {
  478. X            Message("At end of table");
  479. X            break;
  480. X            }
  481. X        }
  482. X    } while(col_hidden[curcol] || !VALID_CELL(p, currow, curcol));
  483. X
  484. X} /* doForwardCell() */
  485. X
  486. Xvoid doBackwardCell()
  487. X/*----------------------------------------------------------------------
  488. X** - Backward to next valid cell
  489. X*/
  490. X{
  491. X    register struct ent *p;
  492. X
  493. X    do {
  494. X        if (curcol) 
  495. X        curcol--;
  496. X        else {
  497. X            if (currow) {
  498. X            while(--currow && row_hidden[currow])
  499. X                    /* NULL */;
  500. X            curcol = maxcols - 1;
  501. X        } else {
  502. X            Message ("At start of table");
  503. X            return;
  504. X            }
  505. X    }
  506. X    } while(col_hidden[curcol] || !VALID_CELL(p, currow, curcol));
  507. X
  508. X} /* doBackwardCell() */
  509. X
  510. X/**********************************************************************
  511. X*       End
  512. X**********************************************************************/
  513. END_OF_FILE
  514.   if test 12902 -ne `wc -c <'ss_12b/ctrl.c'`; then
  515.     echo shar: \"'ss_12b/ctrl.c'\" unpacked with wrong size!
  516.   fi
  517.   # end of 'ss_12b/ctrl.c'
  518. fi
  519. if test -f 'ss_12b/disprange.c' -a "${1}" != "-c" ; then 
  520.   echo shar: Will not clobber existing file \"'ss_12b/disprange.c'\"
  521. else
  522.   echo shar: Extracting \"'ss_12b/disprange.c'\" \(5755 characters\)
  523.   sed "s/^X//" >'ss_12b/disprange.c' <<'END_OF_FILE'
  524. X/**********************************************************************
  525. X* %M%
  526. X* ss     :    A SpreadSheet Program
  527. X*
  528. X* Art's Spreadsheet program.          Art Mulder ( art@cs.ualberta.ca )
  529. X* University of Alberta, Department of Computing Science.
  530. X***********************************************************************
  531. X* Range Display/Manip functions.
  532. X***********************************************************************
  533. X* Functions for displaying ranges' on the spreadsheet.
  534. X* Also, utility functions for accessing/manipulating those ranges.
  535. X***********************************************************************
  536. X#ifndef lint
  537. X  static char Sccsid[] = "%W% %G%";
  538. X#endif
  539. X
  540. X/*
  541. X * Include files
  542. X */
  543. X#include <stdio.h>
  544. X#include <sys/types.h>
  545. X#include <signal.h>
  546. X#include "curses_stuff.h"
  547. X#include <ctype.h>
  548. X
  549. X#include "ss.h"
  550. X#include "keys.h"
  551. X#include "disprange.h"
  552. X
  553. X/*    Function Prototypes
  554. X *----------------------------------------------------------------------
  555. X */
  556. X
  557. X/*    External Global variables
  558. X *----------------------------------------------------------------------
  559. X */
  560. X    extern int showneed;    /* From main.c */
  561. X    extern int  showrange;    /* ditto */
  562. X    extern int running;        /* ditto */
  563. X    extern int anychanged;     /* ditto */
  564. X    extern int showexpr;    /* ditto */
  565. X    extern int ClearScreen;    /* ditto */
  566. X
  567. X    extern int lastmx, lastmy;    /* From screen.c */
  568. X    extern int lastcol, lcols;    /* ditto */
  569. X
  570. X/*********************************************************************/
  571. X
  572. Xvoid RangeToggle()
  573. X/*----------------------------------------------------------------------
  574. X** Toggle Range Display mode.
  575. X** -> If NOT in Range Display Mode, then START Range Display Mode.
  576. X** -> If IN Range Display Mode, then STOP Range Display Mode.
  577. X*/
  578. X{
  579. X  if (showrange == TRUE) {    /* currently IN Range mode */
  580. X    showrange = FALSE;
  581. X    
  582. X  } else {            /* currently NOT in Range mode */
  583. X    showrange = TRUE;
  584. X    showsr = currow;        /* Starting Row of Range */
  585. X    showsc = curcol;        /* Starting Col of Range */
  586. X  }
  587. X  
  588. X} /* RangeToggle() */
  589. X
  590. X/* TEMP */
  591. Xvoid startshow()
  592. X{
  593. X  showrange = 1;
  594. X  showsr = currow;
  595. X  showsc = curcol;
  596. X}
  597. X/* END TEMP */
  598. X
  599. X
  600. X/* insert the range we defined by moving around the screen, see startshow() */
  601. Xvoid showdr()
  602. X{
  603. X    int     minsr, minsc, maxsr, maxsc;
  604. X
  605. X    minsr = showsr < currow ? showsr : currow;
  606. X    minsc = showsc < curcol ? showsc : curcol;
  607. X    maxsr = showsr > currow ? showsr : currow;
  608. X    maxsc = showsc > curcol ? showsc : curcol;
  609. X    (void) sprintf (line+linelim,"%s", r_name(minsr, minsc, maxsr, maxsc));
  610. X}
  611. X
  612. Xchar * RangeGet()
  613. X/*----------------------------------------------------------------------
  614. X** Get & Return the currently highlighted range.  Return "" if
  615. X** no range is currently highlighted.  TURNS OFF RANGE HIGHLIGHTING.
  616. X*/
  617. X{
  618. X    static char CurrentRange[8];    /* no need for more space */
  619. X    int     minsr, minsc, maxsr, maxsc;
  620. X
  621. X    
  622. X    if (showrange == TRUE) {    /* Range IS being displayed */
  623. X        minsr = showsr < currow ? showsr : currow;
  624. X        minsc = showsc < curcol ? showsc : curcol;
  625. X        maxsr = showsr > currow ? showsr : currow;
  626. X        maxsc = showsc > curcol ? showsc : curcol;
  627. X    Sprintf (CurrentRange,"%s", r_name(minsr, minsc, maxsr, maxsc));
  628. X    RangeToggle();
  629. X    
  630. X    } else
  631. X    CurrentRange[0] = '\0';    /* Null Range */
  632. X
  633. X    return CurrentRange;
  634. X    
  635. X} /* RangeGet() */
  636. X
  637. Xvoid RangeGetNum(minr,minc,maxr,maxc)
  638. X/*----------------------------------------------------------------------
  639. X** Get & Return the currently highlighted range -- In numeric form.
  640. X** Return the current cell location (as a range) if no range is
  641. X** currently highlighted.  TURNS OFF RANGE HIGHLIGHTING.
  642. X*/
  643. X   int *minr, *minc,    /* starting row/column of range selected */
  644. X       *maxr, *maxc;    /* ending   row/column of range selected */
  645. X{
  646. X    if (showrange == TRUE) {    /* Range IS being displayed */
  647. X    *minr = showsr < currow ? showsr : currow;
  648. X    *minc = showsc < curcol ? showsc : curcol;
  649. X    *maxr = showsr > currow ? showsr : currow;
  650. X    *maxc = showsc > curcol ? showsc : curcol;
  651. X    RangeToggle();
  652. X    
  653. X    } else {            /* No Range */
  654. X    *minr = currow;    *minc = curcol;
  655. X    *maxr = currow;    *maxc = curcol;
  656. X    }
  657. X} /* RangeGetNum() */
  658. X
  659. X
  660. Xchar *RangeForceInput()
  661. X/*----------------------------------------------------------------------
  662. X** Force the user to input a range (using cursor keys).  Only cursor
  663. X** motion keys are considered to be legal input.  Terminate with a
  664. X** <Tab> or <CR>
  665. X*/
  666. X{
  667. X    register int   c;        /* input */
  668. X    int    anychanged = FALSE;
  669. X
  670. X    /* NOTE: Range display MUST be off before calling
  671. X     * this function.
  672. X     */
  673. X
  674. X    Prompt("Enter Range.  <CR>/<Tab> to accept.");
  675. X    
  676. X    for(;;) {            /* Loop Forever... */
  677. X    update(anychanged);     /* Update Screen */
  678. X
  679. X#ifndef SYSV3            /* HP/Ux 3.1 this may not be wanted */
  680. X/**    (void) refresh();  **/    /* Unix SystemV R3 does a refresh in getch */ 
  681. X#endif
  682. X        c = nmgetch();        /* get next character of input */
  683. X
  684. X    /*
  685. X     * 1) If the input is a cursor-movement command, then
  686. X     * deal with it.
  687. X     */
  688. X    if (ProcessCursorCommands(c) != TRUE) {
  689. X
  690. X        /*
  691. X         * 2) ELSE if it is a <Tab> then start range-show
  692. X         *    mode ONLY if we are not already in range-show
  693. X         *    mode.
  694. X         */
  695. X        if ( (c == kTAB) && (! showrange) )
  696. X        RangeToggle();
  697. X
  698. X        /*
  699. X         * 3) ELSE a <CR> or a <Tab> (in range-show mode)
  700. X         *    signals that the user is done entering a range.
  701. X         */
  702. X        else if ( (c == ctl('m')) || (c == kTAB) )
  703. X        return RangeGet();
  704. X
  705. X/**        else if (c == ' '){ 
  706. X***        Message("** aborted"); 
  707. X***        return NULL;
  708. X***        }
  709. X**/        
  710. X        /*
  711. X         * 4) ELSE, bogus input, beep!
  712. X         */
  713. X        else
  714. X        beep();
  715. X    }
  716. X    }  /* for */
  717. X
  718. X} /* RangeForceInput() */
  719. X
  720. X/**********************************************************************
  721. X*       End
  722. X**********************************************************************/
  723. END_OF_FILE
  724.   if test 5755 -ne `wc -c <'ss_12b/disprange.c'`; then
  725.     echo shar: \"'ss_12b/disprange.c'\" unpacked with wrong size!
  726.   fi
  727.   # end of 'ss_12b/disprange.c'
  728. fi
  729. if test -f 'ss_12b/examples/borrow.ss' -a "${1}" != "-c" ; then 
  730.   echo shar: Will not clobber existing file \"'ss_12b/examples/borrow.ss'\"
  731. else
  732.   echo shar: Extracting \"'ss_12b/examples/borrow.ss'\" \(5491 characters\)
  733.   sed "s/^X//" >'ss_12b/examples/borrow.ss' <<'END_OF_FILE'
  734. X# This data file was generated by the Spreadsheet Calculator.
  735. X# You almost certainly shouldn't edit it.
  736. X
  737. Xformat A 10 4 0
  738. Xformat B 3 1 0
  739. Xformat C 8 2 0
  740. Xformat F 3 2 0
  741. Xleftstring A0 = "How Much Can I Borrow?"
  742. Xleftstring E0 = "If I Can Afford..."
  743. Xlabel B2 = "|"
  744. Xleftstring C2 = "Monthly Payments"
  745. Xlabel F2 = "|"
  746. Xleftstring G2 = "BIWEEKLY payments of:"
  747. Xlet G2 = 0
  748. Xlabel B3 = "|"
  749. Xlet D3 = 700
  750. Xlabel F3 = "|"
  751. Xlet H3 = 300
  752. Xlabel B4 = "|"
  753. Xlabel F4 = "|"
  754. Xrightstring A5 = "Interest"
  755. Xlabel B5 = "|"
  756. Xrightstring C5 = "15 Yrs"
  757. Xrightstring D5 = "20 Yrs"
  758. Xrightstring E5 = "25 Yrs"
  759. Xlabel F5 = "|"
  760. Xrightstring G5 = "15 Yrs"
  761. Xrightstring H5 = "20 Yrs"
  762. Xrightstring I5 = "25 Yrs"
  763. Xrightstring A6 = "--------"
  764. Xlabel B6 = "|"
  765. Xrightstring C6 = "--------"
  766. Xrightstring D6 = "--------"
  767. Xrightstring E6 = "--------"
  768. Xlabel F6 = "|"
  769. Xrightstring G6 = "--------"
  770. Xrightstring H6 = "--------"
  771. Xrightstring I6 = "--------"
  772. Xlet A7 = 0.08
  773. Xlabel B7 = "|"
  774. Xlet C7 = @pv($D$3,$A7/12,15*12)
  775. Xlet D7 = @pv($D$3,$A7/12,20*12)
  776. Xlet E7 = @pv($D$3,$A7/12,25*12)
  777. Xlabel F7 = "|"
  778. Xlet G7 = @pv($H$3,$A7/26,15*26)
  779. Xlet H7 = @pv($H$3,$A7/26,20*26)
  780. Xlet I7 = @pv($H$3,$A7/26,25*26)
  781. Xlet A8 = 0.085
  782. Xlabel B8 = "|"
  783. Xlet C8 = @pv($D$3,$A8/12,15*12)
  784. Xlet D8 = @pv($D$3,$A8/12,20*12)
  785. Xlet E8 = @pv($D$3,$A8/12,25*12)
  786. Xlabel F8 = "|"
  787. Xlet G8 = @pv($H$3,$A8/26,15*26)
  788. Xlet H8 = @pv($H$3,$A8/26,20*26)
  789. Xlet I8 = @pv($H$3,$A8/26,25*26)
  790. Xlet A9 = 0.09
  791. Xlabel B9 = "|"
  792. Xlet C9 = @pv($D$3,$A9/12,15*12)
  793. Xlet D9 = @pv($D$3,$A9/12,20*12)
  794. Xlet E9 = @pv($D$3,$A9/12,25*12)
  795. Xlabel F9 = "|"
  796. Xlet G9 = @pv($H$3,$A9/26,15*26)
  797. Xlet H9 = @pv($H$3,$A9/26,20*26)
  798. Xlet I9 = @pv($H$3,$A9/26,25*26)
  799. Xlet A10 = 0.095
  800. Xlabel B10 = "|"
  801. Xlet C10 = @pv($D$3,$A10/12,15*12)
  802. Xlet D10 = @pv($D$3,$A10/12,20*12)
  803. Xlet E10 = @pv($D$3,$A10/12,25*12)
  804. Xlabel F10 = "|"
  805. Xlet G10 = @pv($H$3,$A10/26,15*26)
  806. Xlet H10 = @pv($H$3,$A10/26,20*26)
  807. Xlet I10 = @pv($H$3,$A10/26,25*26)
  808. Xlet A11 = 0.1
  809. Xlabel B11 = "|"
  810. Xlet C11 = @pv($D$3,$A11/12,15*12)
  811. Xlet D11 = @pv($D$3,$A11/12,20*12)
  812. Xlet E11 = @pv($D$3,$A11/12,25*12)
  813. Xlabel F11 = "|"
  814. Xlet G11 = @pv($H$3,$A11/26,15*26)
  815. Xlet H11 = @pv($H$3,$A11/26,20*26)
  816. Xlet I11 = @pv($H$3,$A11/26,25*26)
  817. Xlet A12 = 0.105
  818. Xlabel B12 = "|"
  819. Xlet C12 = @pv($D$3,$A12/12,15*12)
  820. Xlet D12 = @pv($D$3,$A12/12,20*12)
  821. Xlet E12 = @pv($D$3,$A12/12,25*12)
  822. Xlabel F12 = "|"
  823. Xlet G12 = @pv($H$3,$A12/26,15*26)
  824. Xlet H12 = @pv($H$3,$A12/26,20*26)
  825. Xlet I12 = @pv($H$3,$A12/26,25*26)
  826. Xlet A13 = 0.11
  827. Xlabel B13 = "|"
  828. Xlet C13 = @pv($D$3,$A13/12,15*12)
  829. Xlet D13 = @pv($D$3,$A13/12,20*12)
  830. Xlet E13 = @pv($D$3,$A13/12,25*12)
  831. Xlabel F13 = "|"
  832. Xlet G13 = @pv($H$3,$A13/26,15*26)
  833. Xlet H13 = @pv($H$3,$A13/26,20*26)
  834. Xlet I13 = @pv($H$3,$A13/26,25*26)
  835. Xlet A14 = 0.115
  836. Xlabel B14 = "|"
  837. Xlet C14 = @pv($D$3,$A14/12,15*12)
  838. Xlet D14 = @pv($D$3,$A14/12,20*12)
  839. Xlet E14 = @pv($D$3,$A14/12,25*12)
  840. Xlabel F14 = "|"
  841. Xlet G14 = @pv($H$3,$A14/26,15*26)
  842. Xlet H14 = @pv($H$3,$A14/26,20*26)
  843. Xlet I14 = @pv($H$3,$A14/26,25*26)
  844. Xlet A15 = 0.12
  845. Xlabel B15 = "|"
  846. Xlet C15 = @pv($D$3,$A15/12,15*12)
  847. Xlet D15 = @pv($D$3,$A15/12,20*12)
  848. Xlet E15 = @pv($D$3,$A15/12,25*12)
  849. Xlabel F15 = "|"
  850. Xlet G15 = @pv($H$3,$A15/26,15*26)
  851. Xlet H15 = @pv($H$3,$A15/26,20*26)
  852. Xlet I15 = @pv($H$3,$A15/26,25*26)
  853. Xlet A16 = 0.125
  854. Xlabel B16 = "|"
  855. Xlet C16 = @pv($D$3,$A16/12,15*12)
  856. Xlet D16 = @pv($D$3,$A16/12,20*12)
  857. Xlet E16 = @pv($D$3,$A16/12,25*12)
  858. Xlabel F16 = "|"
  859. Xlet G16 = @pv($H$3,$A16/26,15*26)
  860. Xlet H16 = @pv($H$3,$A16/26,20*26)
  861. Xlet I16 = @pv($H$3,$A16/26,25*26)
  862. Xlet A17 = 0.13
  863. Xlabel B17 = "|"
  864. Xlet C17 = @pv($D$3,$A17/12,15*12)
  865. Xlet D17 = @pv($D$3,$A17/12,20*12)
  866. Xlet E17 = @pv($D$3,$A17/12,25*12)
  867. Xlabel F17 = "|"
  868. Xlet G17 = @pv($H$3,$A17/26,15*26)
  869. Xlet H17 = @pv($H$3,$A17/26,20*26)
  870. Xlet I17 = @pv($H$3,$A17/26,25*26)
  871. Xlet A18 = 0.135
  872. Xlabel B18 = "|"
  873. Xlet C18 = @pv($D$3,$A18/12,15*12)
  874. Xlet D18 = @pv($D$3,$A18/12,20*12)
  875. Xlet E18 = @pv($D$3,$A18/12,25*12)
  876. Xlabel F18 = "|"
  877. Xlet G18 = @pv($H$3,$A18/26,15*26)
  878. Xlet H18 = @pv($H$3,$A18/26,20*26)
  879. Xlet I18 = @pv($H$3,$A18/26,25*26)
  880. Xlet A19 = 0.14
  881. Xlabel B19 = "|"
  882. Xlet C19 = @pv($D$3,$A19/12,15*12)
  883. Xlet D19 = @pv($D$3,$A19/12,20*12)
  884. Xlet E19 = @pv($D$3,$A19/12,25*12)
  885. Xlabel F19 = "|"
  886. Xlet G19 = @pv($H$3,$A19/26,15*26)
  887. Xlet H19 = @pv($H$3,$A19/26,20*26)
  888. Xlet I19 = @pv($H$3,$A19/26,25*26)
  889. Xlet A20 = 0.145
  890. Xlabel B20 = "|"
  891. Xlet C20 = @pv($D$3,$A20/12,15*12)
  892. Xlet D20 = @pv($D$3,$A20/12,20*12)
  893. Xlet E20 = @pv($D$3,$A20/12,25*12)
  894. Xlabel F20 = "|"
  895. Xlet G20 = @pv($H$3,$A20/26,15*26)
  896. Xlet H20 = @pv($H$3,$A20/26,20*26)
  897. Xlet I20 = @pv($H$3,$A20/26,25*26)
  898. Xlet A21 = 0.15
  899. Xlabel B21 = "|"
  900. Xlet C21 = @pv($D$3,$A21/12,15*12)
  901. Xlet D21 = @pv($D$3,$A21/12,20*12)
  902. Xlet E21 = @pv($D$3,$A21/12,25*12)
  903. Xlabel F21 = "|"
  904. Xlet G21 = @pv($H$3,$A21/26,15*26)
  905. Xlet H21 = @pv($H$3,$A21/26,20*26)
  906. Xlet I21 = @pv($H$3,$A21/26,25*26)
  907. Xleftstring A23 = "This spreadsheet answers the question:  How much money can I borrow"
  908. Xleftstring A24 = "(presumably for a mortgage) if I can afford to make payments of X?"
  909. Xleftstring A25 = "The spreadsheet is split into 3 sections.  Column A shows a variety of"
  910. Xleftstring A26 = "different interest rates.  Column C/D/E show how much you can borrow"
  911. Xleftstring A27 = "for 15/20/25 years, at various interest rates, based upon monthly"
  912. Xleftstring A28 = "payments.  Columns G/H/I show what you can borrow if you make"
  913. Xleftstring A29 = "biweekly (every other week) payments."
  914. Xleftstring A31 = "Cell D3 and H3 are the key cells.  You change the value here, to show"
  915. Xleftstring A32 = "how much you can afford as a payment, and then the relevant portion"
  916. Xleftstring A33 = "of the spreadsheet recalculates itself to show how much you can afford"
  917. Xleftstring A34 = "to borrow."
  918. Xgoto A35
  919. END_OF_FILE
  920.   if test 5491 -ne `wc -c <'ss_12b/examples/borrow.ss'`; then
  921.     echo shar: \"'ss_12b/examples/borrow.ss'\" unpacked with wrong size!
  922.   fi
  923.   # end of 'ss_12b/examples/borrow.ss'
  924. fi
  925. if test -f 'ss_12b/examples/payments.ss' -a "${1}" != "-c" ; then 
  926.   echo shar: Will not clobber existing file \"'ss_12b/examples/payments.ss'\"
  927. else
  928.   echo shar: Extracting \"'ss_12b/examples/payments.ss'\" \(5573 characters\)
  929.   sed "s/^X//" >'ss_12b/examples/payments.ss' <<'END_OF_FILE'
  930. X# This data file was generated by the Spreadsheet Calculator.
  931. X# You almost certainly shouldn't edit it.
  932. X
  933. Xformat A 8 4 0
  934. Xformat B 2 1 0
  935. Xformat F 2 1 0
  936. Xleftstring C1 = "If we borrow:"
  937. Xlet E1 = 100000
  938. Xfmt E1 "###,###.00"
  939. Xrightstring B3 = "|"
  940. Xleftstring C3 = " What are the..."
  941. Xrightstring F3 = "|"
  942. Xleftstring G3 = " What are the..."
  943. Xrightstring B4 = "|"
  944. Xleftstring D4 = "Monthly Payments"
  945. Xrightstring F4 = "|"
  946. Xleftstring H4 = "BIWEEKLY payments"
  947. Xrightstring B5 = "|"
  948. Xrightstring F5 = "|"
  949. Xrightstring A6 = "Interest"
  950. Xrightstring B6 = "|"
  951. Xrightstring C6 = "15 Yrs"
  952. Xrightstring D6 = "20 Yrs"
  953. Xrightstring E6 = "25 Yrs"
  954. Xrightstring F6 = "|"
  955. Xrightstring G6 = "15 Yrs"
  956. Xrightstring H6 = "20 Yrs"
  957. Xrightstring I6 = "25 Yrs"
  958. Xrightstring A7 = "--------"
  959. Xrightstring B7 = "|"
  960. Xrightstring C7 = "--------"
  961. Xrightstring D7 = "--------"
  962. Xrightstring E7 = "--------"
  963. Xrightstring F7 = "|"
  964. Xrightstring G7 = "--------"
  965. Xrightstring H7 = "--------"
  966. Xrightstring I7 = "--------"
  967. Xlet A8 = 0.08
  968. Xrightstring B8 = "|"
  969. Xlet C8 = @pmt($E$1,$A8/12,15*12)
  970. Xlet D8 = @pmt($E$1,$A8/12,20*12)
  971. Xlet E8 = @pmt($E$1,$A8/12,25*12)
  972. Xrightstring F8 = "|"
  973. Xlet G8 = @pmt($E$1,$A8/26,15*26)
  974. Xlet H8 = @pmt($E$1,$A8/26,20*26)
  975. Xlet I8 = @pmt($E$1,$A8/26,25*26)
  976. Xlet A9 = 0.085
  977. Xrightstring B9 = "|"
  978. Xlet C9 = @pmt($E$1,$A9/12,15*12)
  979. Xlet D9 = @pmt($E$1,$A9/12,20*12)
  980. Xlet E9 = @pmt($E$1,$A9/12,25*12)
  981. Xrightstring F9 = "|"
  982. Xlet G9 = @pmt($E$1,$A9/26,15*26)
  983. Xlet H9 = @pmt($E$1,$A9/26,20*26)
  984. Xlet I9 = @pmt($E$1,$A9/26,25*26)
  985. Xlet A10 = 0.09
  986. Xrightstring B10 = "|"
  987. Xlet C10 = @pmt($E$1,$A10/12,15*12)
  988. Xlet D10 = @pmt($E$1,$A10/12,20*12)
  989. Xlet E10 = @pmt($E$1,$A10/12,25*12)
  990. Xrightstring F10 = "|"
  991. Xlet G10 = @pmt($E$1,$A10/26,15*26)
  992. Xlet H10 = @pmt($E$1,$A10/26,20*26)
  993. Xlet I10 = @pmt($E$1,$A10/26,25*26)
  994. Xlet A11 = 0.095
  995. Xrightstring B11 = "|"
  996. Xlet C11 = @pmt($E$1,$A11/12,15*12)
  997. Xlet D11 = @pmt($E$1,$A11/12,20*12)
  998. Xlet E11 = @pmt($E$1,$A11/12,25*12)
  999. Xrightstring F11 = "|"
  1000. Xlet G11 = @pmt($E$1,$A11/26,15*26)
  1001. Xlet H11 = @pmt($E$1,$A11/26,20*26)
  1002. Xlet I11 = @pmt($E$1,$A11/26,25*26)
  1003. Xlet A12 = 0.1
  1004. Xrightstring B12 = "|"
  1005. Xlet C12 = @pmt($E$1,$A12/12,15*12)
  1006. Xlet D12 = @pmt($E$1,$A12/12,20*12)
  1007. Xlet E12 = @pmt($E$1,$A12/12,25*12)
  1008. Xrightstring F12 = "|"
  1009. Xlet G12 = @pmt($E$1,$A12/26,15*26)
  1010. Xlet H12 = @pmt($E$1,$A12/26,20*26)
  1011. Xlet I12 = @pmt($E$1,$A12/26,25*26)
  1012. Xlet A13 = 0.105
  1013. Xrightstring B13 = "|"
  1014. Xlet C13 = @pmt($E$1,$A13/12,15*12)
  1015. Xlet D13 = @pmt($E$1,$A13/12,20*12)
  1016. Xlet E13 = @pmt($E$1,$A13/12,25*12)
  1017. Xrightstring F13 = "|"
  1018. Xlet G13 = @pmt($E$1,$A13/26,15*26)
  1019. Xlet H13 = @pmt($E$1,$A13/26,20*26)
  1020. Xlet I13 = @pmt($E$1,$A13/26,25*26)
  1021. Xlet A14 = 0.11
  1022. Xrightstring B14 = "|"
  1023. Xlet C14 = @pmt($E$1,$A14/12,15*12)
  1024. Xlet D14 = @pmt($E$1,$A14/12,20*12)
  1025. Xlet E14 = @pmt($E$1,$A14/12,25*12)
  1026. Xrightstring F14 = "|"
  1027. Xlet G14 = @pmt($E$1,$A14/26,15*26)
  1028. Xlet H14 = @pmt($E$1,$A14/26,20*26)
  1029. Xlet I14 = @pmt($E$1,$A14/26,25*26)
  1030. Xlet A15 = 0.115
  1031. Xrightstring B15 = "|"
  1032. Xlet C15 = @pmt($E$1,$A15/12,15*12)
  1033. Xlet D15 = @pmt($E$1,$A15/12,20*12)
  1034. Xlet E15 = @pmt($E$1,$A15/12,25*12)
  1035. Xrightstring F15 = "|"
  1036. Xlet G15 = @pmt($E$1,$A15/26,15*26)
  1037. Xlet H15 = @pmt($E$1,$A15/26,20*26)
  1038. Xlet I15 = @pmt($E$1,$A15/26,25*26)
  1039. Xlet A16 = 0.12
  1040. Xrightstring B16 = "|"
  1041. Xlet C16 = @pmt($E$1,$A16/12,15*12)
  1042. Xlet D16 = @pmt($E$1,$A16/12,20*12)
  1043. Xlet E16 = @pmt($E$1,$A16/12,25*12)
  1044. Xrightstring F16 = "|"
  1045. Xlet G16 = @pmt($E$1,$A16/26,15*26)
  1046. Xlet H16 = @pmt($E$1,$A16/26,20*26)
  1047. Xlet I16 = @pmt($E$1,$A16/26,25*26)
  1048. Xlet A17 = 0.125
  1049. Xrightstring B17 = "|"
  1050. Xlet C17 = @pmt($E$1,$A17/12,15*12)
  1051. Xlet D17 = @pmt($E$1,$A17/12,20*12)
  1052. Xlet E17 = @pmt($E$1,$A17/12,25*12)
  1053. Xrightstring F17 = "|"
  1054. Xlet G17 = @pmt($E$1,$A17/26,15*26)
  1055. Xlet H17 = @pmt($E$1,$A17/26,20*26)
  1056. Xlet I17 = @pmt($E$1,$A17/26,25*26)
  1057. Xlet A18 = 0.13
  1058. Xrightstring B18 = "|"
  1059. Xlet C18 = @pmt($E$1,$A18/12,15*12)
  1060. Xlet D18 = @pmt($E$1,$A18/12,20*12)
  1061. Xlet E18 = @pmt($E$1,$A18/12,25*12)
  1062. Xrightstring F18 = "|"
  1063. Xlet G18 = @pmt($E$1,$A18/26,15*26)
  1064. Xlet H18 = @pmt($E$1,$A18/26,20*26)
  1065. Xlet I18 = @pmt($E$1,$A18/26,25*26)
  1066. Xlet A19 = 0.135
  1067. Xrightstring B19 = "|"
  1068. Xlet C19 = @pmt($E$1,$A19/12,15*12)
  1069. Xlet D19 = @pmt($E$1,$A19/12,20*12)
  1070. Xlet E19 = @pmt($E$1,$A19/12,25*12)
  1071. Xrightstring F19 = "|"
  1072. Xlet G19 = @pmt($E$1,$A19/26,15*26)
  1073. Xlet H19 = @pmt($E$1,$A19/26,20*26)
  1074. Xlet I19 = @pmt($E$1,$A19/26,25*26)
  1075. Xlet A20 = 0.14
  1076. Xrightstring B20 = "|"
  1077. Xlet C20 = @pmt($E$1,$A20/12,15*12)
  1078. Xlet D20 = @pmt($E$1,$A20/12,20*12)
  1079. Xlet E20 = @pmt($E$1,$A20/12,25*12)
  1080. Xrightstring F20 = "|"
  1081. Xlet G20 = @pmt($E$1,$A20/26,15*26)
  1082. Xlet H20 = @pmt($E$1,$A20/26,20*26)
  1083. Xlet I20 = @pmt($E$1,$A20/26,25*26)
  1084. Xlet A21 = 0.145
  1085. Xrightstring B21 = "|"
  1086. Xlet C21 = @pmt($E$1,$A21/12,15*12)
  1087. Xlet D21 = @pmt($E$1,$A21/12,20*12)
  1088. Xlet E21 = @pmt($E$1,$A21/12,25*12)
  1089. Xrightstring F21 = "|"
  1090. Xlet G21 = @pmt($E$1,$A21/26,15*26)
  1091. Xlet H21 = @pmt($E$1,$A21/26,20*26)
  1092. Xlet I21 = @pmt($E$1,$A21/26,25*26)
  1093. Xlet A22 = 0.15
  1094. Xrightstring B22 = "|"
  1095. Xlet C22 = @pmt($E$1,$A22/12,15*12)
  1096. Xlet D22 = @pmt($E$1,$A22/12,20*12)
  1097. Xlet E22 = @pmt($E$1,$A22/12,25*12)
  1098. Xrightstring F22 = "|"
  1099. Xlet G22 = @pmt($E$1,$A22/26,15*26)
  1100. Xlet H22 = @pmt($E$1,$A22/26,20*26)
  1101. Xlet I22 = @pmt($E$1,$A22/26,25*26)
  1102. Xleftstring D24 = "NOTES"
  1103. Xleftstring A26 = "* Cell E1 contains the amount that we are considering borrowing.  "
  1104. Xleftstring A27 = "  This is the value that the entire spreadsheet depends upon.  "
  1105. Xleftstring A28 = "  This spreadsheet plays a game of 'what-if'.  You choose a value"
  1106. Xleftstring A29 = "  for E1, and then the spreadsheet shows you what the payments would"
  1107. Xleftstring A30 = "  be to pay back a mortgage in that amount."
  1108. Xleftstring A32 = "EG:  Cell D14 shows what the monthly payments would be on a 20 year"
  1109. Xleftstring A33 = "     mortgage, at 11% interest.  (On $100,000.00 this is $1,032.19)"
  1110. Xgoto A33
  1111. END_OF_FILE
  1112.   if test 5573 -ne `wc -c <'ss_12b/examples/payments.ss'`; then
  1113.     echo shar: \"'ss_12b/examples/payments.ss'\" unpacked with wrong size!
  1114.   fi
  1115.   # end of 'ss_12b/examples/payments.ss'
  1116. fi
  1117. if test -f 'ss_12b/help.c' -a "${1}" != "-c" ; then 
  1118.   echo shar: Will not clobber existing file \"'ss_12b/help.c'\"
  1119. else
  1120.   echo shar: Extracting \"'ss_12b/help.c'\" \(5617 characters\)
  1121.   sed "s/^X//" >'ss_12b/help.c' <<'END_OF_FILE'
  1122. X/*
  1123. X * -> writing "help" has begun, but only just, and so it is
  1124. X *    currently not installed.  I'm not sure whether it is 
  1125. X *    worth the work involved to install it.
  1126. X */
  1127. X
  1128. X/**********************************************************************
  1129. X* %M%
  1130. X* ss     :    A SpreadSheet Program
  1131. X*
  1132. X* Art's Spreadsheet program.          Art Mulder ( art@cs.ualberta.ca )
  1133. X* University of Alberta, Department of Computing Science.
  1134. X***********************************************************************
  1135. X* Help Module
  1136. X***********************************************************************
  1137. X* Functions for displaying help
  1138. X**********************************************************************/
  1139. X#ifndef lint
  1140. X  static char Sccsid[] = "%W% %G%";
  1141. X#endif
  1142. X
  1143. X/*
  1144. X * Include files
  1145. X */
  1146. X#include <stdio.h>
  1147. X#include <sys/types.h>
  1148. X#include <signal.h>
  1149. X#include "curses_stuff.h"
  1150. X#include <ctype.h>
  1151. X
  1152. X#include "ss.h"
  1153. X#include "keys.h"
  1154. X
  1155. X/*    External Global variables
  1156. X *----------------------------------------------------------------------
  1157. X */
  1158. X    extern int showneed;    /* From main.c */
  1159. X    extern int showrange;    /* ditto */
  1160. X    extern int running;        /* ditto */
  1161. X    extern int anychanged;     /* ditto */
  1162. X    extern int showexpr;    /* ditto */
  1163. X    extern int ClearScreen;    /* ditto */
  1164. X
  1165. X    extern int FullUpdate;    /* ditto */
  1166. X
  1167. X    extern int lastmx, lastmy;    /* From screen.c */
  1168. X    extern int lastcol, lcols;    /* ditto */
  1169. X
  1170. X/*    Internal Global variables
  1171. X *----------------------------------------------------------------------
  1172. X */
  1173. X
  1174. X#define HelpSize 21
  1175. Xstatic char *Help[] =  {
  1176. X "- Top-Level Commands: --------------------------------------------------",
  1177. X "  / : Main Menu |  0-9 @ = - + . : Number or Function Entry",
  1178. X "  ? : Help      |  \" < >         : Centred, Right, Left Justified String",
  1179. X "      Any other input results in entering a Left Justifed string",
  1180. X "",
  1181. X "- Cursor Movement: -----------------------------------------------------",
  1182. X "   <Left>, ^B : Left one Cell  | <Home>, <Esc> < : Go to A0",
  1183. X "  <Right>, ^F : Right one Cell | <End>, <Esc> > : End of Col",
  1184. X "   <Down>, ^N : Down one Cell  | <PgUp>, <Esc> v : Page Up",
  1185. X "     <Up>, ^P : Up one Cell    | <PgDn>, ^V,     : Page Down",
  1186. X "           ^T : Top of Col     | <Sh><Left>, ^X <    : Page Left",
  1187. X "           ^A : Start of Row   | <Sh><Right>, ^X >    : Page Right",
  1188. X "           ^E : End of Row     | <Esc> b : Back, to previous valid Cell",
  1189. X "                               | <Esc> f : Forward, to next valid Cell",
  1190. X "- Operations: ----------------------------------------------------------",
  1191. X "  ^X-v           : Edit Cell Value  | ^L    : Redraw screen                ",
  1192. X "  ^X-l           : Edit Cell Label  | ^R    : Redraw; Highlight Values     ",
  1193. X "  ^G             : Goto a Cell      | ^K    : Redraw; Highlight Expressions",
  1194. X "  ^W             : Mark Cell        | <Tab> : Toggle Range display. ",
  1195. X "  ^Y             : Yank marked Cell | ^Z    : Stop program",
  1196. X " <Del>, <BS>, ^D : Erase Cell",
  1197. X  };
  1198. X/*
  1199. X * Keep an alternate arrangement also:
  1200. X *
  1201. X- Top-Level Commands: --------------------------------------------------
  1202. X              /       : Main Menu",
  1203. X              ?       : Help",
  1204. X        0-9 @ = - + . : Number or Function Entry",
  1205. X           \" < >     : Centred, Right or Left Justified String",
  1206. X
  1207. X    Any other input results in entering a Left Justifed string",
  1208. X
  1209. X- Cursor Movement: -----------------------------------------------------
  1210. X      <Left>, ^B      : Left one Cell
  1211. X     <Right>, ^F      : Right one Cell
  1212. X      <Down>, ^N      : Down one Cell
  1213. X        <Up>, ^P      : Up one Cell
  1214. X      <Home>, <Esc> < : Go to A0
  1215. X       <End>, <Esc> > : End of Col
  1216. X      <PgUp>, <Esc> v : Page Up
  1217. X      <PgDn>, ^V,     : Page Down
  1218. X  <Sh><Left>, ^X <    : Page Left
  1219. X <Sh><Right>, ^X >    : Page Right
  1220. X              ^T      : Top of Col
  1221. X              ^A      : Start of Row
  1222. X              ^E      : End of Row 
  1223. X              <Esc> b : Back, to previous valid Cell
  1224. X              <Esc> f : Forward, to next valid Cell
  1225. X             <Return> : Move right or down (depends on -C,-R program flag)
  1226. X
  1227. X- Operations: ----------------------------------------------------------
  1228. X              ^G      : Goto a Cell
  1229. X              ^W      : Mark Cell
  1230. X              ^Y      : Yank previously marked Cell
  1231. X              ^X-v    : Edit Cell Value
  1232. X              ^X-l    : Edit Cell Label
  1233. X      <Del>, <BS>, ^D : Erase the current Cell (Value and Label)
  1234. X              ^L      : Redraw screen                 | 
  1235. X              ^R      : Redraw; Highlight Values      |
  1236. X              ^K      : Redraw; Highlight Expressions |
  1237. X              <Tab>   : Toggle Range display. 
  1238. X              ^Z      : Stop program
  1239. X------------------------------------------------------------------------
  1240. X**/
  1241. X
  1242. X/*    Internal Function Prototypes
  1243. X ***********************************************************************
  1244. X */
  1245. X
  1246. X
  1247. X/*    Externally Accessible Functions
  1248. X ***********************************************************************
  1249. X */
  1250. X
  1251. Xvoid help(context)
  1252. X/*----------------------------------------------------------------------
  1253. X** 
  1254. X*/
  1255. X  int context;        /* Help Context */
  1256. X{
  1257. X    int row = 3;
  1258. X    int x;
  1259. X
  1260. X    (void) move(0,0);
  1261. X    (void) clrtobot();
  1262. X
  1263. X    switch (context) {
  1264. X      case HELP:    /* top level help */
  1265. X    for (x=0; x<HelpSize; x++)
  1266. X      mvaddstr(row++, 0, Help[x]);
  1267. X    break;
  1268. X
  1269. X      default:        /* unknown help context */
  1270. X    break;        /* shouldn't happen */
  1271. X    }
  1272. X
  1273. X    Prompt("** Strike any key to continue");
  1274. X    (void) nmgetch();
  1275. X
  1276. X    FullUpdate++;
  1277. X    Refresh();    
  1278. X
  1279. X} /* help() */
  1280. X
  1281. X
  1282. X/**********************************************************************
  1283. X*       End
  1284. X**********************************************************************/
  1285. END_OF_FILE
  1286.   if test 5617 -ne `wc -c <'ss_12b/help.c'`; then
  1287.     echo shar: \"'ss_12b/help.c'\" unpacked with wrong size!
  1288.   fi
  1289.   # end of 'ss_12b/help.c'
  1290. fi
  1291. if test -f 'ss_12b/menu_cell.c' -a "${1}" != "-c" ; then 
  1292.   echo shar: Will not clobber existing file \"'ss_12b/menu_cell.c'\"
  1293. else
  1294.   echo shar: Extracting \"'ss_12b/menu_cell.c'\" \(5259 characters\)
  1295.   sed "s/^X//" >'ss_12b/menu_cell.c' <<'END_OF_FILE'
  1296. X/**********************************************************************
  1297. X* %M%
  1298. X* Art Mulder ( art@cs.ualberta.ca )
  1299. X* University of Alberta, Department of Computing Science.
  1300. X***********************************************************************
  1301. X* Cell Menu Operations
  1302. X***********************************************************************
  1303. X**********************************************************************/
  1304. X#ifndef lint
  1305. X  static char Sccsid[] = "%W% %G%";
  1306. X#endif
  1307. X
  1308. X/*
  1309. X * Include files
  1310. X */
  1311. X#include <stdio.h>
  1312. X#include <string.h>
  1313. X#include "curses_stuff.h"
  1314. X
  1315. X#include "ss.h"
  1316. X#include "getinput.h"
  1317. X#include "menu_cell.h" 
  1318. X
  1319. X/*    Internal Macros & Data Structures
  1320. X *----------------------------------------------------------------------
  1321. X */
  1322. X
  1323. X/*    External Global variables
  1324. X *----------------------------------------------------------------------
  1325. X */
  1326. X
  1327. X
  1328. X/*    Externally Accessible Functions
  1329. X ***********************************************************************
  1330. X */
  1331. X
  1332. X
  1333. Xvoid CellGoto()
  1334. X/*----------------------------------------------------------------------
  1335. X** Goto a Cell (or the location of a ``name'').
  1336. X*/
  1337. X{
  1338. X    Message("** Goto: Enter Cell (or cell name) to go to");
  1339. X    buff = gi_line();
  1340. X    ABORT_AND_RETURN_IF_BUFF_NULL;
  1341. X    Sprintf (line, "goto [v] %s", buff);
  1342. X    ClearMessage;
  1343. X    PROCESS_line;
  1344. X} /* CellGoto() */
  1345. X
  1346. Xvoid CellMark()
  1347. X/*----------------------------------------------------------------------
  1348. X** Mark a cell.  The cell is then available to the CellCopy command.
  1349. X*/
  1350. X{
  1351. X    Message("** Cell marked for later copying.");
  1352. X    savedrow = currow;
  1353. X    savedcol = curcol;
  1354. X} /* CellMark() */
  1355. X
  1356. Xvoid CellCopy()
  1357. X/*----------------------------------------------------------------------
  1358. X** Copy a cell that was previous Marked [ CellMark() ] into the
  1359. X** current cell.
  1360. X*/
  1361. X{
  1362. X     
  1363. X    register struct ent *p = *ATBL(tbl, savedrow, savedcol);
  1364. X    register struct ent *n;
  1365. X    
  1366. X    if (!p)            /* Make sure the marked cell exists */
  1367. X    return;
  1368. X
  1369. X    Message("** Previously marked cell copied.");
  1370. X    n = lookat (currow, curcol);
  1371. X    (void) clearent(n);
  1372. X    copyent( n, p, currow - savedrow, curcol - savedcol);
  1373. X    FullUpdate++;
  1374. X    modflg++;
  1375. X    
  1376. X} /* CellCopy() */
  1377. X
  1378. Xvoid CellEditLabel()
  1379. X/*----------------------------------------------------------------------
  1380. X** Edit the String portion of a cell's contents.
  1381. X**
  1382. X** NOTE: based on edits() in interp.c
  1383. X*/
  1384. X{
  1385. X    register struct ent *p;    /* To point to the current cell */
  1386. X     
  1387. X    if (locked_cell(currow, curcol)) { 
  1388. X    Message("** Current cell is LOCKED, Edit aborted");
  1389. X    beep();
  1390. X    return;
  1391. X    }
  1392. X
  1393. X    Message("** Edit Cell Label");
  1394. X    p = lookat (currow, curcol);
  1395. X    if (p->label)        /* A Label exists */
  1396. X    buff = gi_editline( p->label);
  1397. X    else            /* No Label exists, input one! */
  1398. X    buff = gi_line();
  1399. X    ABORT_AND_RETURN_IF_BUFF_NULL;
  1400. X
  1401. X    if( p->flags&is_label )
  1402. X        Sprintf(line, "label %s = \"%s\"", v_name(currow, curcol),
  1403. X        buff);
  1404. X    else
  1405. X    Sprintf(line, "%sstring %s = \"%s\"",
  1406. X        ((p->flags&is_leftflush) ? "left" : "right"),
  1407. X        v_name(currow, curcol),
  1408. X        buff);
  1409. X
  1410. X    ClearMessage;
  1411. X
  1412. X    linelim = 0;    
  1413. X    (void) yyparse ();
  1414. X    linelim = -1;    
  1415. X
  1416. X} /* CellEditLabel() */
  1417. X
  1418. X
  1419. Xvoid CellEditValue()
  1420. X/*----------------------------------------------------------------------
  1421. X** Edit the Value (number/function etc) portion of a cell's contents.
  1422. X*/
  1423. X{
  1424. X    register struct ent *p;
  1425. X   
  1426. X    if (locked_cell(currow, curcol)) { 
  1427. X    Message("** Current cell is LOCKED, Edit aborted");
  1428. X    beep();
  1429. X    return;
  1430. X    }
  1431. X
  1432. X    Message("** Edit Cell Value");
  1433. X    p = lookat (currow, curcol);
  1434. X
  1435. X    /*
  1436. X     * Ugh, this is a Horrible Hack -> to take the easy way
  1437. X     * out and avoid figuring out some obscure code.
  1438. X     * Fix it some time!
  1439. X     *
  1440. X     * NOTE: based on editv() in interp.c
  1441. X     */
  1442. X    line[0] = '\0';
  1443. X    linelim = 0;
  1444. X    if (p->flags & is_strexpr || p->expr == 0) {
  1445. X        Sprintf (line+linelim, "%.15g", p->v);
  1446. X        linelim += strlen (line+linelim);
  1447. X    } else {
  1448. X        editexp(currow,curcol);
  1449. X    }
  1450. X    /** END "Horrible Hack", continue with regular hack :-) **/
  1451. X
  1452. X    buff = gi_editline( line );
  1453. X    linelim = -1;
  1454. X    ABORT_AND_RETURN_IF_BUFF_NULL;
  1455. X    
  1456. X    Sprintf(line, "let %s = %s", v_name(currow, curcol), buff);
  1457. X    ClearMessage;
  1458. X    PROCESS_line;
  1459. X
  1460. X} /* CellEditValue() */
  1461. X
  1462. X
  1463. X/*    Internal Functions
  1464. X ***********************************************************************
  1465. X */
  1466. X
  1467. X/*
  1468. X** NOTE: the ability to erase a single cell is not considered
  1469. X** necessary, since you can achieve the same thing through the
  1470. X** Edit menu.  the function is preserved here for informative
  1471. X** purposes.
  1472. X**
  1473. X** HMMMM: May want to bind this to like the backspace key, to zap
  1474. X** the contents of the cell under the ptr.  Bear it in mind.
  1475. X**/
  1476. X
  1477. X/*----------------------------------------------------------------------
  1478. X** Erase the contents of the current cell.
  1479. X*/
  1480. X
  1481. X/* void CellErase()
  1482. X** {
  1483. X**     register struct ent **pp;
  1484. X**
  1485. X**     flush_saved();
  1486. X**     pp = ATBL(tbl, currow, curcol);
  1487. X**     if ((*pp) && !locked_cell(currow, curcol)) {
  1488. X**        if (*pp) {
  1489. X**       free_ent(*pp);
  1490. X**       *pp = (struct ent *)0;
  1491. X**        }
  1492. X**     }
  1493. X**     sync_refs();
  1494. X**     modflg++;
  1495. X**     FullUpdate++;
  1496. X** 
  1497. X** }
  1498. X*/
  1499. X
  1500. X/**********************************************************************
  1501. X*       End
  1502. X**********************************************************************/
  1503. END_OF_FILE
  1504.   if test 5259 -ne `wc -c <'ss_12b/menu_cell.c'`; then
  1505.     echo shar: \"'ss_12b/menu_cell.c'\" unpacked with wrong size!
  1506.   fi
  1507.   # end of 'ss_12b/menu_cell.c'
  1508. fi
  1509. if test -f 'ss_12b/range.c' -a "${1}" != "-c" ; then 
  1510.   echo shar: Will not clobber existing file \"'ss_12b/range.c'\"
  1511. else
  1512.   echo shar: Extracting \"'ss_12b/range.c'\" \(5887 characters\)
  1513.   sed "s/^X//" >'ss_12b/range.c' <<'END_OF_FILE'
  1514. X
  1515. X/*    SC    A Spreadsheet Calculator
  1516. X *        Range Manipulations
  1517. X *
  1518. X *              Robert Bond, 4/87
  1519. X *
  1520. X *        $Revision: 6.21 $
  1521. X */
  1522. X
  1523. X#ifndef lint
  1524. X  static char Sccsid[] = "%W% %G%";
  1525. X#endif
  1526. X
  1527. X#include <sys/types.h>
  1528. X#ifdef BSD42
  1529. X#include <strings.h>
  1530. X#else
  1531. X#ifndef SYSIII
  1532. X#include <string.h>
  1533. X#endif
  1534. X#endif
  1535. X
  1536. X#include <stdio.h>
  1537. X#include "curses_stuff.h"
  1538. X#include <ctype.h>
  1539. X#include "ss.h"
  1540. X
  1541. Xstatic struct range *rng_base;
  1542. X
  1543. Xvoid
  1544. Xadd_range(name, left, right, is_range)
  1545. Xchar *name;
  1546. Xstruct ent_ptr left, right;
  1547. Xint is_range;
  1548. X{
  1549. X    struct range *r;
  1550. X    register char *p;
  1551. X    int len;
  1552. X    int minr,minc,maxr,maxc;
  1553. X    int minrf, mincf, maxrf, maxcf;
  1554. X    register struct ent *rcp;
  1555. X
  1556. X    if (left.vp->row < right.vp->row) {
  1557. X    minr = left.vp->row; minrf = left.vf & FIX_ROW;
  1558. X    maxr = right.vp->row; maxrf = right.vf & FIX_ROW;
  1559. X    } else {
  1560. X    minr = right.vp->row; minrf = right.vf & FIX_ROW;
  1561. X    maxr = left.vp->row; maxrf = right.vf & FIX_ROW;
  1562. X    } 
  1563. X
  1564. X    if (left.vp->col < right.vp->col) {
  1565. X    minc = left.vp->col; mincf = left.vf & FIX_COL;
  1566. X    maxc = right.vp->col; maxcf = right.vf & FIX_COL;
  1567. X    } else {
  1568. X    minc = right.vp->col; mincf = right.vf & FIX_COL;
  1569. X    maxc = left.vp->col; maxcf = left.vf & FIX_COL;
  1570. X    } 
  1571. X
  1572. X    left.vp = lookat(minr, minc);
  1573. X    left.vf = minrf | mincf;
  1574. X    right.vp = lookat(maxr, maxc);
  1575. X    right.vf = maxrf | maxcf;
  1576. X
  1577. X    if (find_range(name, strlen(name), (struct ent *)0, (struct ent *)0)) {
  1578. X    error("Error: range name already defined");
  1579. X    Free(name);
  1580. X    return;
  1581. X    }
  1582. X
  1583. X    if (strlen(name) <= 2) {
  1584. X    error("Invalid range name - too short");
  1585. X    Free(name);
  1586. X    return;
  1587. X    }
  1588. X
  1589. X    for(p=name, len=0; *p; p++, len++)
  1590. X    if (!((isalpha(*p) && (len<=2)) ||
  1591. X        ((isdigit(*p) || isalpha(*p) || (*p == '_')) && (len>2)))) {
  1592. X        error("Invalid range name - illegal combination");
  1593. X        Free(name);
  1594. X        return;
  1595. X    }
  1596. X    if(autolabel && minc>0 && !is_range) {
  1597. X    rcp = lookat(minr,minc-1);
  1598. X    if (rcp->label==0 && rcp->expr==0 && rcp->v==0)
  1599. X        label(rcp, name, 0);
  1600. X    }
  1601. X
  1602. X    r = (struct range *)Malloc((unsigned)sizeof(struct range));
  1603. X    r->r_name = name;
  1604. X    r->r_left = left;
  1605. X    r->r_right = right;
  1606. X    r->r_next = rng_base;
  1607. X    r->r_prev = (struct range *)0;
  1608. X    r->r_is_range = is_range;
  1609. X    if (rng_base)
  1610. X        rng_base->r_prev = r;
  1611. X    rng_base = r;
  1612. X}
  1613. X
  1614. Xvoid
  1615. Xdel_range(left, right)
  1616. Xstruct ent *left, *right;
  1617. X{
  1618. X    register struct range *r;
  1619. X    int minr,minc,maxr,maxc;
  1620. X
  1621. X    minr = left->row < right->row ? left->row : right->row;
  1622. X    minc = left->col < right->col ? left->col : right->col;
  1623. X    maxr = left->row > right->row ? left->row : right->row;
  1624. X    maxc = left->col > right->col ? left->col : right->col;
  1625. X
  1626. X    left = lookat(minr, minc);
  1627. X    right = lookat(maxr, maxc);
  1628. X
  1629. X    if (!(r = find_range((char *)0, 0, left, right))) 
  1630. X    return;
  1631. X
  1632. X    if (r->r_next)
  1633. X        r->r_next->r_prev = r->r_prev;
  1634. X    if (r->r_prev)
  1635. X        r->r_prev->r_next = r->r_next;
  1636. X    else
  1637. X    rng_base = r->r_next;
  1638. X    Free((char *)(r->r_name));
  1639. X    Free((char *)r);
  1640. X}
  1641. X
  1642. Xvoid
  1643. Xclean_range()
  1644. X{
  1645. X    register struct range *r;
  1646. X    register struct range *nextr;
  1647. X
  1648. X    r = rng_base;
  1649. X    rng_base = (struct range *)0;
  1650. X
  1651. X    while (r) {
  1652. X    nextr = r->r_next;
  1653. X    Free((char *)(r->r_name));
  1654. X    Free((char *)r);
  1655. X    r = nextr;
  1656. X    }
  1657. X}
  1658. X
  1659. X/* Match on name or lmatch, rmatch */
  1660. X
  1661. Xstruct range *
  1662. Xfind_range(name, len, lmatch, rmatch)
  1663. Xchar *name;
  1664. Xint len;
  1665. Xstruct ent *lmatch;
  1666. Xstruct ent *rmatch;
  1667. X{
  1668. X    struct range *r;
  1669. X    register char *rp, *np;
  1670. X    register int c;
  1671. X
  1672. X    if (name) {
  1673. X    for (r = rng_base; r; r = r->r_next) {
  1674. X        for (np = name, rp = r->r_name, c = len;
  1675. X         c && *rp && (*rp == *np);
  1676. X         rp++, np++, c--) /* */;
  1677. X        if (!c && !*rp)
  1678. X        return(r);
  1679. X    }
  1680. X    return((struct range *)0);
  1681. X    }
  1682. X
  1683. X    for (r = rng_base; r; r= r->r_next) {
  1684. X    if ((lmatch == r->r_left.vp) && (rmatch == r->r_right.vp)) 
  1685. X        return(r);
  1686. X    }
  1687. X    return((struct range *)0);
  1688. X}
  1689. X
  1690. Xvoid
  1691. Xsync_ranges()
  1692. X{
  1693. X    register struct range *r;
  1694. X
  1695. X    r = rng_base;
  1696. X    while(r) {
  1697. X    r->r_left.vp = lookat(r->r_left.vp->row, r->r_left.vp->col);
  1698. X    r->r_right.vp = lookat(r->r_right.vp->row, r->r_right.vp->col);
  1699. X    r = r->r_next;
  1700. X    }
  1701. X}
  1702. X
  1703. Xvoid
  1704. Xwrite_range(f)
  1705. XFILE *f;
  1706. X{
  1707. X    register struct range *r;
  1708. X
  1709. X    for (r = rng_base; r; r = r->r_next) {
  1710. X    (void) fprintf(f, "define \"%s\" %s%s%s%d",
  1711. X            r->r_name,
  1712. X            r->r_left.vf & FIX_COL ? "$":"",
  1713. X            coltoa(r->r_left.vp->col), 
  1714. X            r->r_left.vf & FIX_ROW ? "$":"",
  1715. X            r->r_left.vp->row);
  1716. X    if (r->r_is_range)
  1717. X        (void) fprintf(f, ":%s%s%s%d\n",
  1718. X                r->r_right.vf & FIX_COL ? "$":"",
  1719. X                coltoa(r->r_right.vp->col), 
  1720. X                r->r_right.vf & FIX_ROW ? "$":"",
  1721. X                r->r_right.vp->row);
  1722. X    else
  1723. X        (void) fprintf(f, "\n");
  1724. X    }
  1725. X}
  1726. X
  1727. Xvoid
  1728. Xlist_range(f)
  1729. XFILE *f;
  1730. X{
  1731. X    register struct range *r;
  1732. X
  1733. X    (void) fprintf(f, "%-30s %s\n\n","Name","Definition");
  1734. X
  1735. X    for (r = rng_base; r; r = r->r_next) {
  1736. X    (void) fprintf(f, "%-30s %s%s%s%d",
  1737. X                r->r_name,
  1738. X                r->r_left.vf & FIX_COL ? "$":"",
  1739. X                coltoa(r->r_left.vp->col), 
  1740. X                r->r_left.vf & FIX_ROW ? "$":"",
  1741. X                r->r_left.vp->row);
  1742. X    if (r->r_is_range)
  1743. X        (void) fprintf(f, ":%s%s%s%d\n",
  1744. X                r->r_right.vf & FIX_COL ? "$":"",
  1745. X                coltoa(r->r_right.vp->col), 
  1746. X                r->r_right.vf & FIX_ROW ? "$":"",
  1747. X                r->r_right.vp->row);
  1748. X    else
  1749. X        (void) fprintf(f, "\n");
  1750. X    }
  1751. X}
  1752. X
  1753. Xchar *
  1754. Xv_name(row, col)
  1755. Xint row, col;
  1756. X{
  1757. X    struct ent *v;
  1758. X    struct range *r;
  1759. X    static char buf[20];
  1760. X
  1761. X    v = lookat(row, col);
  1762. X    if (r = find_range((char *)0, 0, v, v)) {
  1763. X    return(r->r_name);
  1764. X    } else {
  1765. X        (void) sprintf(buf, "%s%d", coltoa(col), row);
  1766. X    return(buf);
  1767. X    }
  1768. X}
  1769. X
  1770. Xchar *
  1771. Xr_name(r1, c1, r2, c2)
  1772. Xint r1, c1, r2, c2;
  1773. X{
  1774. X    struct ent *v1, *v2;
  1775. X    struct range *r;
  1776. X    static char buf[100];
  1777. X
  1778. X    v1 = lookat(r1, c1);
  1779. X    v2 = lookat(r2, c2);
  1780. X    if (r = find_range((char *)0, 0, v1, v2)) {
  1781. X    return(r->r_name);
  1782. X    } else {
  1783. X        (void) sprintf(buf, "%s", v_name(r1, c1));
  1784. X    (void) sprintf(buf+strlen(buf), ":%s", v_name(r2, c2));
  1785. X    return(buf);
  1786. X    }
  1787. X}
  1788. X
  1789. Xint
  1790. Xare_ranges()
  1791. X{
  1792. X    return (rng_base != 0);
  1793. X}
  1794. END_OF_FILE
  1795.   if test 5887 -ne `wc -c <'ss_12b/range.c'`; then
  1796.     echo shar: \"'ss_12b/range.c'\" unpacked with wrong size!
  1797.   fi
  1798.   # end of 'ss_12b/range.c'
  1799. fi
  1800. if test -f 'ss_12b/sunfkeys/f1.c' -a "${1}" != "-c" ; then 
  1801.   echo shar: Will not clobber existing file \"'ss_12b/sunfkeys/f1.c'\"
  1802. else
  1803.   echo shar: Extracting \"'ss_12b/sunfkeys/f1.c'\" \(2254 characters\)
  1804.   sed "s/^X//" >'ss_12b/sunfkeys/f1.c' <<'END_OF_FILE'
  1805. X
  1806. X/*
  1807. X * Art Mulder.  arc@cs.ualberta.ca
  1808. X *
  1809. X * A simple curses program to see if we can identify function keys.  
  1810. X *
  1811. X * USAGE: f1
  1812. X *   Then try pressing function keys.  The program will identify
  1813. X *   which key you have pressed, IF IT CAN.  Enter an 'x' to exit
  1814. X *   the program.
  1815. X */
  1816. X
  1817. X#include<curses.h>
  1818. X
  1819. Xmain()
  1820. X{
  1821. X  int c;
  1822. X
  1823. X/*
  1824. X * Initialize Curses
  1825. X */
  1826. X  initscr();
  1827. X  noecho();
  1828. X  cbreak();    /* start cbreak mode on terminal */
  1829. X  nonl();    /* stop mapping return to newline */
  1830. X  scrollok(stdscr,TRUE);
  1831. X  idlok(stdscr,TRUE);
  1832. X
  1833. X  keypad(stdscr, TRUE);
  1834. X  notimeout(stdscr,TRUE);    /* for slower systems (ie: Sun3) */
  1835. X  refresh();
  1836. X
  1837. X/* 
  1838. X * begin input/display loop
  1839. X */
  1840. X  move (0,0);
  1841. X  printw("Enter Function Key, 'x' to exit.\n");
  1842. X
  1843. X  while ( (c = getch()) != 'x' ) {        /* x = exit */
  1844. X    clrtoeol();
  1845. X    printw("%o: ",c);
  1846. X    switch(c) {
  1847. X    case KEY_F(1) : printw("F1\n"); break;    /* Function keys */
  1848. X    case KEY_F(2) : printw("F2\n"); break;
  1849. X    case KEY_F(3) : printw("F3\n"); break;
  1850. X    case KEY_F(4) : printw("F4\n"); break;
  1851. X    case KEY_F(5) : printw("F5\n"); break;
  1852. X    case KEY_F(6) : printw("F6\n"); break;
  1853. X    case KEY_F(7) : printw("F7\n"); break;
  1854. X    case KEY_F(8) : printw("F8\n"); break;
  1855. X    case KEY_F(9) : printw("F9\n"); break;
  1856. X    case KEY_F(10) : printw("F10\n"); break;
  1857. X    case KEY_F(11) : printw("F11\n"); break;
  1858. X    case KEY_F(12) : printw("F12\n"); break;
  1859. X
  1860. X    case KEY_LEFT:  printw("Left Arrow\n"); break;    /* Keypad keys */
  1861. X    case KEY_RIGHT: printw("Right Arrow\n"); break;
  1862. X    case KEY_UP:    printw("Up Arrow\n"); break;
  1863. X    case KEY_DOWN:  printw("Down Arrow\n"); break;
  1864. X    case KEY_HOME:  printw("HOME\n"); break;
  1865. X    case KEY_END:   printw("END\n"); break;
  1866. X    case KEY_PPAGE: printw("PgUp\n"); break;
  1867. X    case KEY_NPAGE: printw("PgDn\n"); break;
  1868. X    case KEY_IC: printw("Insert\n"); break;
  1869. X    case KEY_ENTER: printw("Enter\n"); break;
  1870. X    case KEY_SLEFT: printw("<shift>LEFT\n"); break;
  1871. X    case KEY_SRIGHT: printw("<shift>RIGHT\n"); break;
  1872. X    case KEY_SHOME: printw("<shift>HOME\n"); break;
  1873. X    case KEY_SEND: printw("<shift>END\n"); break;
  1874. X
  1875. X    default:
  1876. X      printw("Unkown input.\n");
  1877. X    }
  1878. X
  1879. X    refresh();
  1880. X  }
  1881. X
  1882. X/*
  1883. X * Move cursor to bottom left corner of screen and end curses.
  1884. X */
  1885. X  move((LINES-1),0);
  1886. X  refresh();
  1887. X  endwin();
  1888. X}
  1889. END_OF_FILE
  1890.   if test 2254 -ne `wc -c <'ss_12b/sunfkeys/f1.c'`; then
  1891.     echo shar: \"'ss_12b/sunfkeys/f1.c'\" unpacked with wrong size!
  1892.   fi
  1893.   # end of 'ss_12b/sunfkeys/f1.c'
  1894. fi
  1895. if test -f 'ss_12b/vmtbl.c' -a "${1}" != "-c" ; then 
  1896.   echo shar: Will not clobber existing file \"'ss_12b/vmtbl.c'\"
  1897. else
  1898.   echo shar: Extracting \"'ss_12b/vmtbl.c'\" \(5353 characters\)
  1899.   sed "s/^X//" >'ss_12b/vmtbl.c' <<'END_OF_FILE'
  1900. X/*    SC    A Spreadsheet Calculator
  1901. X *        Spreadsheet 'tbl' creation
  1902. X *
  1903. X *        original by James Gosling, September 1982
  1904. X *        modifications by Mark Weiser and Bruce Israel,
  1905. X *            University of Maryland
  1906. X *
  1907. X *              More mods Robert Bond, 12/86
  1908. X *        More mods by Alan Silverstein, 3-4/88, see list of changes.
  1909. X *        Currently supported by sequent!sawmill!buhrt (Jeff Buhrt)
  1910. X *        $Revision: 6.21 $
  1911. X *
  1912. X */
  1913. X
  1914. X#ifndef lint
  1915. X  static char Sccsid[] = "%W% %G%";
  1916. X#endif
  1917. X
  1918. X#ifdef PSC
  1919. X# include <stdio.h>
  1920. X#else /* PSC */
  1921. X# include "curses_stuff.h"
  1922. X#endif /* PSC */
  1923. X
  1924. X#include "ss.h"
  1925. X
  1926. X/*
  1927. X * check to see if *rowp && *colp are currently allocated, if not expand the
  1928. X * current size if we can.
  1929. X */
  1930. X#ifndef PSC
  1931. Xvoid
  1932. Xcheckbounds(rowp, colp)
  1933. Xint    *rowp;
  1934. Xint    *colp;
  1935. X{
  1936. X    if (*rowp < 0)
  1937. X        *rowp = 0;
  1938. X    else if (*rowp >= maxrows)
  1939. X    {    if (*colp >= maxcols)
  1940. X        {    if (!growtbl(GROWBOTH, *rowp, *colp))
  1941. X            {    *rowp = maxrows -1;
  1942. X                *colp = maxcols -1;
  1943. X            }
  1944. X            return;
  1945. X        }
  1946. X        else
  1947. X        {    if (!growtbl(GROWROW, *rowp, 0))
  1948. X                *rowp = maxrows-1;
  1949. X            return;
  1950. X        }
  1951. X    }
  1952. X    if (*colp < 0) 
  1953. X        *colp = 0;
  1954. X    else if (*colp >= maxcols)
  1955. X    {    if (!growtbl(GROWCOL, 0, *colp))
  1956. X            *colp = maxcols-1;
  1957. X    }
  1958. X}
  1959. X#endif /* !PSC */
  1960. X    
  1961. X/* Realloc will just Malloc if oldptr is == NULL */
  1962. X#define GROWALLOC(newptr, oldptr, nelem, type, msg) \
  1963. X    newptr = (type *)Realloc((char *)oldptr, \
  1964. X                     (unsigned)(nelem*sizeof(type))); \
  1965. X    if (newptr == (type *)NULL) \
  1966. X    {   error(msg); \
  1967. X        return(FALSE); \
  1968. X    } \
  1969. X    oldptr = newptr /* wait incase we can't alloc */
  1970. X
  1971. Xstatic    char    nolonger[] = "The table can't be any longer";
  1972. Xstatic    char    nowider[] = "The table can't be any wider";
  1973. X
  1974. X/*
  1975. X * grow the main && auxiliary tables (reset maxrows/maxcols as needed)
  1976. X * toprow &&/|| topcol tell us a better guess of how big to become.
  1977. X * we return TRUE if we could grow, FALSE if not....
  1978. X */
  1979. Xint
  1980. Xgrowtbl(rowcol, toprow, topcol)
  1981. Xint    rowcol;
  1982. Xint    toprow, topcol;
  1983. X{
  1984. X    struct ent ***tbl2;
  1985. X    struct ent ** nullit;
  1986. X    int    cnt;
  1987. X    int    *fwidth2;
  1988. X    int    *precision2;
  1989. X    int     *realfmt2;
  1990. X    char    *col_hidden2;
  1991. X    char    *row_hidden2;
  1992. X    int    newrows, newcols;
  1993. X    int    i;
  1994. X
  1995. X#ifndef PSC
  1996. X    newrows = maxrows;
  1997. X#endif /* !PSC */
  1998. X
  1999. X    newcols = maxcols;
  2000. X    if (rowcol == GROWNEW)
  2001. X    {
  2002. X#ifndef PSC
  2003. X        maxrows = toprow = 0;
  2004. X        /* when we first start up, fill the screen w/ cells */
  2005. X        {    int startval;
  2006. X            startval = LINES - RESROW;
  2007. X            newrows = startval > MINROWS ? startval : MINROWS;
  2008. X            startval = ((COLS) - RESCOL) / DEFWIDTH;
  2009. X            newcols = startval > MINCOLS ? startval : MINCOLS;
  2010. X        }
  2011. X#else
  2012. X        newcols = MINCOLS;
  2013. X#endif /* !PSC */
  2014. X        maxcols = topcol = 0;
  2015. X    }
  2016. X#ifndef PSC
  2017. X    /* set how much to grow */
  2018. X    if ((rowcol == GROWROW) || (rowcol == GROWBOTH))
  2019. X    {    if (toprow > maxrows)
  2020. X            newrows = GROWAMT + toprow;
  2021. X        else
  2022. X            newrows += GROWAMT;
  2023. X    }
  2024. X#endif /* !PSC */
  2025. X    if ((rowcol == GROWCOL) || (rowcol == GROWBOTH))
  2026. X    {    if ((rowcol == GROWCOL) && ((maxcols == ABSMAXCOLS) ||
  2027. X                    (topcol >= ABSMAXCOLS)))
  2028. X        {    error(nowider);
  2029. X            return(FALSE);
  2030. X        }
  2031. X
  2032. X        if (topcol > maxcols)
  2033. X            newcols = GROWAMT + topcol;
  2034. X        else
  2035. X            newcols += GROWAMT;
  2036. X
  2037. X        if (newcols > ABSMAXCOLS)
  2038. X            newcols = ABSMAXCOLS;
  2039. X    }
  2040. X
  2041. X#ifndef PSC
  2042. X    if ((rowcol == GROWROW) || (rowcol == GROWBOTH) || (rowcol == GROWNEW))
  2043. X    {
  2044. X        struct ent *** lnullit;
  2045. X        int    lcnt;
  2046. X
  2047. X        GROWALLOC(row_hidden2, row_hidden, newrows, char, nolonger);
  2048. X        memset(row_hidden+maxrows, 0, (newrows-maxrows)*sizeof(char));
  2049. X
  2050. X        /*
  2051. X         * alloc tbl row pointers, per net.lang.c, calloc does not
  2052. X         * necessarily fill in NULL pointers
  2053. X         */
  2054. X        GROWALLOC(tbl2, tbl, newrows, struct ent **, nolonger);
  2055. X        for(lnullit = tbl+maxrows, lcnt = 0; lcnt < newrows-maxrows;
  2056. X                            lcnt++, lnullit++)
  2057. X            *lnullit = (struct ent **)NULL;
  2058. X/*        memset(tbl+maxrows, (char *)NULL, (newrows-maxrows)*(sizeof(struct ent **)));*/
  2059. X    }
  2060. X#endif /* !PSC */
  2061. X
  2062. X    if ((rowcol == GROWCOL) || (rowcol == GROWBOTH) || (rowcol == GROWNEW))
  2063. X    {
  2064. X        GROWALLOC(fwidth2, fwidth, newcols, int, nowider);
  2065. X        GROWALLOC(precision2, precision, newcols, int, nowider);
  2066. X        GROWALLOC(realfmt2, realfmt, newcols, int, nowider);
  2067. X#ifdef PSC
  2068. X        memset(fwidth+maxcols, 0, (newcols-maxcols)*sizeof(int));
  2069. X        memset(precision+maxcols, 0, (newcols-maxcols)*sizeof(int));
  2070. X        memset(realfmt+maxcols, 0, (newcols-maxcols)*sizeof(int));
  2071. X    }
  2072. X#else
  2073. X        GROWALLOC(col_hidden2, col_hidden, newcols, char, nowider);
  2074. X        memset(col_hidden+maxcols, 0, (newcols-maxcols)*sizeof(char));
  2075. X        for (i = maxcols; i < newcols; i++) {
  2076. X            fwidth[i] = DEFWIDTH;
  2077. X            precision[i] = DEFPREC;
  2078. X            realfmt[i]= DEFREFMT;
  2079. X        }
  2080. X
  2081. X        /* [re]alloc the space for each row */
  2082. X        for (i = 0; i < maxrows; i++)
  2083. X        {
  2084. X            if ((tbl[i] = (struct ent **)Realloc((char *)tbl[i],
  2085. X            (unsigned)(newcols * sizeof(struct ent **)))) == (struct ent **)0)
  2086. X            {    error(nowider);
  2087. X                return(FALSE);
  2088. X            }
  2089. X        for(nullit = ATBL(tbl, i, maxcols), cnt = 0;
  2090. X                cnt < newcols-maxcols; cnt++, nullit++)
  2091. X            *nullit = (struct ent *)NULL;
  2092. X/*        memset((char *)ATBL(tbl,i, maxcols), 0,
  2093. X               (newcols-maxcols)*sizeof(struct ent **));
  2094. X*/               
  2095. X        }
  2096. X    }
  2097. X    else
  2098. X        i = maxrows;
  2099. X
  2100. X    /* fill in the bottom of the table */
  2101. X    for (; i < newrows; i++)
  2102. X    {    if ((tbl[i] = (struct ent **)Malloc((unsigned)(newcols *
  2103. X                sizeof(struct ent **)))) == (struct ent **)0)
  2104. X        {    error(nowider);
  2105. X            return(FALSE);
  2106. X        }
  2107. X        for(nullit = tbl[i], cnt = 0; cnt < newcols; cnt++, nullit++)
  2108. X            *nullit = (struct ent *)NULL;
  2109. X/*        memset((char *)tbl[i], 0, newcols*sizeof(struct ent **));*/
  2110. X    }
  2111. X
  2112. X    FullUpdate++;
  2113. X    maxrows = newrows;
  2114. X#endif /* PSC */
  2115. X
  2116. X    maxcols = newcols;
  2117. X    return(TRUE);
  2118. X}
  2119. END_OF_FILE
  2120.   if test 5353 -ne `wc -c <'ss_12b/vmtbl.c'`; then
  2121.     echo shar: \"'ss_12b/vmtbl.c'\" unpacked with wrong size!
  2122.   fi
  2123.   # end of 'ss_12b/vmtbl.c'
  2124. fi
  2125. echo shar: End of archive 9 \(of 11\).
  2126. cp /dev/null ark9isdone
  2127. MISSING=""
  2128. for I in 1 2 3 4 5 6 7 8 9 10 11 ; do
  2129.     if test ! -f ark${I}isdone ; then
  2130.     MISSING="${MISSING} ${I}"
  2131.     fi
  2132. done
  2133. if test "${MISSING}" = "" ; then
  2134.     echo You have unpacked all 11 archives.
  2135.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2136. else
  2137.     echo You still must unpack the following archives:
  2138.     echo "        " ${MISSING}
  2139. fi
  2140. exit 0
  2141. exit 0 # Just in case...
  2142.