home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / EFFO / pd7.lzh / SRC / help.c < prev    next >
Text File  |  1990-04-14  |  16KB  |  411 lines

  1. /*
  2.  * Help functions for sc
  3.  * R. Bond, 1988
  4.  * $Revision: 6.2 $
  5.  */
  6.  
  7. #ifdef OSK
  8. #  include <stdio.h>
  9. #endif
  10.  
  11. #include <curses.h>
  12. #include "sc.h"
  13.  
  14. char *intro[] = {
  15. " ",
  16. " Overview:",
  17. " ",
  18. " A:   This overview",
  19. " B:   Options",
  20. " C:   Cursor movement commands",
  21. " D:   Cell entry and editing commands",
  22. " E:   File commands",
  23. " F:   Row and column commands",
  24. " G:   Range commands",
  25. " H:   Miscellaneous commands",
  26. " I:   Variable names/Expressions",
  27. " J:   Range functions",
  28. " K:   Numeric functions",
  29. " L:   String functions",
  30. " M:   Financial functions",
  31. " N:   Time and date functions",
  32. " ",
  33. " Q:   Return to main spreadsheet",
  34. 0
  35. };
  36.  
  37. char *options[] = {
  38. " ",
  39. " B: Options",
  40. " ",
  41. "     ^To  Toggle options. Toggle one option selected by o:",
  42. " ",
  43. "          a    Recalculate automatically or on ``@'' commands.",
  44. "          c    Current cell highlighting enable/disable.",
  45. "          e    External function execution enable/disable.",
  46. "          n    If enabled, a digit starts a numeric value.",
  47. "          t    Top line display enable/disable.",
  48. "          x    Encrypt/decrypt database and listing files.",
  49. "          $    Dollar prescale.  If enabled, all numeric constants.",
  50. "               (not expressions) entered are multipled by 0.01.",
  51. " ",
  52. "     S    Set options.  Options include:",
  53. " ",
  54. "          byrows        Recalculate in row order. (default)",
  55. "          bycols        Recalculate in column order.",
  56. "          iterations=n  Set the number of iterations allowed. (10)",
  57. "          tblstyle=xx   Set ``T'' output style to:",
  58. "                        0 (none), tex, latex, or tbl.",
  59. 0
  60. };
  61.  
  62. char *cursor[] = {
  63. " ",
  64. " C: Cell cursor movement (always OK):",
  65. " ",
  66. "     ^N ^P ^B ^F Down, up, back, forward",
  67. "     ^Ed         Go to end of range.  Follow ^E by a direction indicator",
  68. "                 such as ^P or j.",
  69. "     Arrow keys (if the terminal and termcap support them.)",
  70. " ",
  71. " Cell cursor movement if no prompt active:",
  72. "     j,k,l,h    Down, up, right, left",
  73. "     SPACE      Forward",
  74. "     ^H         Back",
  75. "     TAB        Forward, otherwise starts/ends a range",
  76. "     ^          Up to row 0 of the current column.",
  77. "     #          Down to the last valid row of the current column.",
  78. "     0          Back to column A.  Preface with ^U if numeric mode.",
  79. "     $          Forward to the last valid column of the current row.",
  80. "     b          Back then up to the previous valid cell.",
  81. "     w          Forward then down to the next valid cell.",
  82. "     g          Go to a cell.  Cell name, range name, quoted string,",
  83. "                or a number specify which cell.",
  84. 0
  85. };
  86.  
  87.  
  88. char *cell[] = {
  89. " ",
  90. " D: Cell entry and editing commands:",
  91. " ",
  92. "     =    Enter a numeric constant or expression.",
  93. "     <    Enter a left justified string or string expression.",
  94. "     \",>  Enter a right justified string or string expression.",
  95. "     e    Edit the current cell's numeric value.",
  96. "     E    Edit the current cell's string part.",
  97. "     x    Clear the current cell.",
  98. "     c    Copy the last marked cell to the current cell.",
  99. "     m    Mark a cell to be used as the source for ``c''",
  100. "     +    Increment numeric part",
  101. "     -    Decrement numeric part",
  102. " ",
  103. "     In numeric mode, a decimal digit, ``+'', ``-'', and ``.'' all start",
  104. "     a new numeric constant or expression.",
  105. 0
  106. };
  107.  
  108.  
  109. char *file[] = {
  110. " ",
  111. " E: File commands:",
  112. " ",
  113. "     G    Get a new database from a file. ",
  114. "     M    Merge a new file into the current database.",
  115. "     P    Put the current database into a file.",
  116. "     W    Write a listing of the current database into a file in",
  117. "          a form that matches its appearance on the screen.",
  118. "     T    Write a listing of the current database to a file, but",
  119. "          put delimiters between each pair of fields.",
  120. "          Optionally brackets output with control lines for ``tbl'',",
  121. "          ``LaTeX'', or ``TeX''.",
  122. " ",
  123. "     If encryption mode is set, file I/O will be encrypted/decrypted.",
  124. "     ``\"| program\"'' for a file name will pipe (unencrypted) output to",
  125. "     a program for Put, Write and Table.  If a cell name is used",
  126. "     as the file name, the cell's string part will be used as the",
  127. "     file name.",
  128. 0
  129. };
  130.  
  131.  
  132. char *row[] = {
  133. " ",
  134. " F: Row and column commands:",
  135. " ",
  136. "     ir, ic      Insert a new, empty row (column)",
  137. "     ar, ac      Append a new copy of the current row (column)",
  138. "     dr, dc      Delete the current row (column)",
  139. "     pr, pc, pm  Pull deleted cells back into the spreadsheet",
  140. "                 Insert rows, columns or merge the cells.",
  141. "     vr, vc      Remove expressions from the affected rows (columns),",
  142. "                 leaving only the values.",
  143. "     zr, zc      Hide (``zap'') the current row (column)",
  144. "     sr, sc      Show hidden rows (columns)",
  145. "     f           Set the output format to be used with the values of",
  146. "                 each cell in this column.  Enter field width and",
  147. "                 number of fractional digits.  A preceding count can be",
  148. "                 used to change more than one column.",
  149. " ",
  150. "     Commands which move or copy cells also modify the row and column ",
  151. "     references in the new cell expressions.  Use ``fixed'' or the",
  152. "     ``$'' style cell reference to supress the change.",
  153. 0
  154. };
  155.  
  156.  
  157. char *range[] = {
  158. " ",
  159. " G: Range commands:",
  160. " ",
  161. "     /x   Clear a range. ",
  162. "     /v   Remove the expressions from a range of cells, leaving ",
  163. "          just the values.",
  164. "     /c   Copy a source range to a destination range.",
  165. "     /f   Fill a range with constant values starting with a given",
  166. "          value and increasing by a given increment.",
  167. "     /d   Assign a name to a cell or a range of cells.  Give the",
  168. "          the name, surrounded by quotes, and either a cell name such",
  169. "          as ``A10'' or a range such as ``a1:b20''.",
  170. "     /s   Shows the currently defined range names.  Pipe output to",
  171. "          sort, then to less.",
  172. "     /u   Use this command to undefine a previously defined range",
  173. "          name.",
  174. " ",
  175. "     Range operations affect a rectangular region on the screen",
  176. "     defined by the upper left and lower right cells in the region.",
  177. "     A range is specified by giving the cell names separated by ``:'',",
  178. "     such as ``a20:k52''.  Another way to refer to a range is to use",
  179. "     a name previously defined using ``/d''.",
  180. 0
  181. };
  182.  
  183.  
  184. char *misc[] = {
  185. " ",
  186. " H: Miscellaneous commands:",
  187. " ",
  188. "     Q q ^C   Exit from the program.",
  189. "     ^G ESC   Abort entry of the current command.",
  190. "     ?        Help",
  191. "     !        Shell escape.  Enter a command to run.  ``!!'' repeats",
  192. "              the last command.  Just ``!'' starts an interactive shell.",
  193. "     ^L       Redraw the screen.",
  194. "     ^R       Redraw the screen.  Highlight cells with values but no",
  195. "              expressions.",
  196. "     ^X       Redraw the screen.  Show formulas, not values.",
  197. "     @        Recalculate the spreadsheet.",
  198. "     ^V       Type, in the command line, the name of the current cell.",
  199. "     ^W       Type, in the command line, the current cell's expression.",
  200. "     ^A       Type, in the command line, the current cell's numeric value.",
  201. "     TAB      When the character cursor is on the top line TAB can be used",
  202. "              to start or stop the display of the default range.",
  203. 0
  204. };
  205.  
  206. char *var[] = {
  207. " ",
  208. " I: Variable names:",
  209. " ",
  210. "     K20    Row and column can vary on copies.",
  211. "     $K$20  Row and column stay fixed on copies.",
  212. "     $K20   Row can vary; column stays fixed on copies.",
  213. "     K$20   Row stays fixed; column can vary on copies.",
  214. "     fixed  holds following expession fixed on copies.",
  215. "     Cells and ranges can also be assigned a symbolic name via the",
  216. "     range command ``/d''.",
  217. " ",
  218. " Expressions:",
  219. "     -e      Negation                e<=e  Less than or equal",
  220. "     e+e     Addition                e=e   Equal",
  221. "     e-e     Subtraction             e!=e  Not Equal",
  222. "     e*e     Multiplication          e>=e  Greater than or equal",
  223. "     e/e     Division                e>e  Greater than",
  224. "     e%e     Modulo                  e<e  Less than",
  225. "     e^e     Exponentiation          e&e  Boolean operator AND.",
  226. "     ~e      Boolean operator NOT    e|e     Boolean operator OR",
  227. "     e?e1:e2 Conditional: If the e is non zero then then e1, otherwise e2.",
  228. "     Terms may be constants, variable names, and parenthesized expressions.",
  229. 0
  230. };
  231.  
  232. char *rangef[] = {
  233. " ",
  234. " J: Range functions:",
  235. " ",
  236. "     @sum(r)           Sum all valid cells in the range.",
  237. "     @prod(r)          Multiply together all valid cells in the range.",
  238. "     @avg(r)           Average all valid cells in range.",
  239. "     @max(r)           Return the maximum value in the range.",
  240. "     @min(r)           Return the minimum value in the range.",
  241. "                       See also the numeric versions of max and min.",
  242. "     @stddev(r)        Return the sample standard deviation of ",
  243. "                       the cells in the range.",
  244. "     @index(e,r)       Return the numeric value of the cell at index e",
  245. "                       into range r.",
  246. "     @stindex(e,r)     Return the string value of the cell at index e",
  247. "                       into range r.",
  248. "     @lookup(e,r)      Search through the range r for a value that",
  249. "                       matches e.  The value returned is that from the",
  250. "                       next row and the same column as the match, if",
  251. "                       the range was a single row, or the value from",
  252. "                       the next column and the same row as the match if",
  253. "                       the range was a single column.",
  254. 0
  255. };
  256.  
  257. char *numericf[] = {
  258. " ",
  259. " K: Numeric functions:",
  260. " ",
  261. "     @atan2(e1,e2)     Arc tangent of e1/e2.",
  262. "     @ceil(e)          Smallest integer not less than e.",
  263. "     @eqs(se1,se2)     1 if string expr se1 has the same value as se2.",
  264. "     @exp(e)           Exponential function of e.",
  265. "     @fabs(e)          Absolute value of e.",
  266. "     @floor(e)         The largest integer not greater than e.",
  267. "     @hypot(x,y)       Sqrt(x*x+y*y).",
  268. "     @max(e1,e2,...)   The maximum of the values of the e's.",
  269. "     @min(e1,e2,...)   The minimum of the values of the e's",
  270. "     @nval(se,e)       The numeric value of a named cell.",
  271. "     pi                A constant quite close to pi.",
  272. "     @pow(e1,e2)       e1 raised to the power of e2.",
  273. "     @rnd(e)           Round e to the nearest integer.",
  274. "     @sqrt(e)          Square root of e.",
  275. "     @ston(se)         Convert string expr se to a numeric",
  276. "     @ln(e)   @log(e)           Natural/base 10 logarithm of e.",
  277. "     @dtr(e)  @rtd(e)           Convert degrees to/from radians.",
  278. "     @cos(e)  @sin(e)  @tan(e)  Trig functions of radian arguments.",
  279. "     @asin(e) @acos(e) @atan(e) Inverse trig function.",
  280. 0
  281. };
  282.  
  283. char *stringf[] = {
  284. " ",
  285. " L: String functions:",
  286. " ",
  287. "     #                 Concatenate strings.  For example, the",
  288. "                       string expression ``A0 # \"zy dog\"'' yields",
  289. "                       ``the lazy dog'' if A0 is ``the la''.",
  290. "     @substr(se,e1,e2) Extract characters e1 through e2 from the",
  291. "                       string expression se.  For example,",
  292. "                       ``@substr(\"Nice jacket\" 4, 7)'' yields ",
  293. "                       ``e jac''.",
  294. "     @fmt(se,e)        Convert a number to a string using sprintf(3).",
  295. "                       For example,  ``@fmt(\"*%6.3f*\",10.5)'' yields",
  296. "                       ``*10.500*''.  Use formats are e, E, f, g, and G.",
  297. "     @sval(se,e)       Return the string value of a cell selected by name.",
  298. "     @ext(se,e)        Call an external function (program or",
  299. "                       script).  Convert e to a string and append it",
  300. "                       to the command line as an argument.  @ext yields",
  301. "                       a string: the first line printed to standard",
  302. "                       output by the command.",
  303. "     String expressions are made up of constant strings (characters",
  304. "     surrounded by quotes), variables, and string functions.",
  305. 0
  306. };
  307.  
  308.  
  309. char *finf[] = {
  310. " ",
  311. " M: Financial functions:",
  312. " ",
  313. "     @pmt(e1,e2,e3)    @pmt(60000,.01,360) computes the monthly",
  314. "                       payments for a $60000 mortgage at 12%",
  315. "                       annual interest (.01 per month) for 30",
  316. "                       years (360 months).",
  317. " ",
  318. "     @fv(e1,e2,e3)     @fv(100,.005,36) computes the future value",
  319. "                       for of 36 monthly payments of $100 at 6%",
  320. "                       interest (.005 per month).  It answers the",
  321. "                       question:  ``How much will I have in 2",
  322. "                       years if I deposit $100 per month in a",
  323. "                       savings account paying 6% interest com-",
  324. "                       pounded monthly?''",
  325. " ",
  326. "     @pv(e1,e2,e3)     @pv(1000,.015,36) computes the present",
  327. "                       value of an a ordinary annuity of 36",
  328. "                       monthly payments of $1000 at 18% annual",
  329. "                       interest.  It answers the question: ``How",
  330. "                       much can I borrow at 18% for 30 years if I",
  331. "                       pay $1000 per month?''",
  332. 0
  333. };
  334.  
  335.  
  336. char *timef[] = {
  337. " ",
  338. " N: Time and date functions:",
  339. " ",
  340. "     @now              Return the current time encoded as the",
  341. "                       number of seconds since December 31, 1969,",
  342. "                       midnight, GMT.",
  343. " ",
  344. "     All of the following take an argument expressed in seconds:",
  345. " ",
  346. "     @date(e)          Convert the time in seconds to a date",
  347. "                       string 24 characters long in the following",
  348. "                       form: ``Sun Sep 16 01:03:52 1973''.  Note",
  349. "                       that you can extract pieces of this fixed format",
  350. "                       string with @substr.",
  351. "     @year(e)          Return the year.  Valid years begin with 1970.",
  352. "     @month(e)         Return the month: 1 (Jan) to 12 (Dec).",
  353. "     @day(e)           Return the day of the month: 1 to 31.",
  354. "     @hour(e)          Return the number of hours since midnight: 0 to 23.",
  355. "     @minute(e)        Return the number of minutes since the",
  356. "                       last full hour: 0 to 59.",
  357. "     @second(e)        Return the number of seconds since the",
  358. "                       last full minute: 0 to 59.",
  359. 0
  360. };
  361.  
  362. help()
  363. {
  364.     int option;
  365.     char **ns = intro;
  366.  
  367.     while((option = pscreen(ns)) != 'q' && option != 'Q') {
  368.         switch (option) {
  369.         case 'a': case 'A': ns = intro; break;
  370.         case 'b': case 'B': ns = options; break;
  371.         case 'c': case 'C': ns = cursor; break;
  372.         case 'd': case 'D': ns = cell; break;
  373.         case 'e': case 'E': ns = file; break;
  374.         case 'f': case 'F': ns = row; break;
  375.         case 'g': case 'G': ns = range; break;
  376.         case 'h': case 'H': ns = misc; break;
  377.         case 'i': case 'I': ns = var; break;
  378.         case 'j': case 'J': ns = rangef; break;
  379.         case 'k': case 'K': ns = numericf; break;
  380.         case 'l': case 'L': ns = stringf; break;
  381.         case 'm': case 'M': ns = finf; break;
  382.         case 'n': case 'N': ns = timef; break;
  383.         default: ns = intro; break;
  384.         }
  385.     }
  386.     FullUpdate++;
  387.     (void) move(1,0);
  388.     (void) clrtobot();
  389. }
  390.  
  391. pscreen(screen)
  392. char *screen[];
  393. {
  394.     int line;
  395.     int dbline;
  396.  
  397.     (void) move(1,0);
  398.     (void) clrtobot();
  399.     dbline = 1;
  400.     for (line = 0; screen[line]; line++) {
  401.         (void) move(dbline++, 4);
  402.         (void) addstr (screen[line]);
  403.         (void) clrtoeol();
  404.     }
  405.     (void) move(0,0);
  406.     (void) printw("Which Screen? [a-n, q]");
  407.     (void) clrtoeol();
  408.     (void) refresh();
  409.     return(nmgetch());
  410. }
  411.