home *** CD-ROM | disk | FTP | other *** search
/ Math Solutions 1995 October / Math_Solutions_CD-ROM_Walnut_Creek_October_1995.iso / pc / mac / discrete / doc / environm.tex < prev    next >
Encoding:
Text File  |  1993-05-05  |  33.5 KB  |  774 lines

  1. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2. %%
  3. %A  environm.tex                GAP documentation            Martin Schoenert
  4. %%
  5. %A  @(#)$Id: environm.tex,v 3.8 1993/02/19 10:48:42 gap Exp $
  6. %%
  7. %Y  Copyright 1990-1992,  Lehrstuhl D fuer Mathematik,  RWTH Aachen,  Germany
  8. %%
  9. %%  This chapter describes the functions and facilites of {\GAP} environment.
  10. %%
  11. %H  $Log: environm.tex,v $
  12. %H  Revision 3.8  1993/02/19  10:48:42  gap
  13. %H  adjustments in line length and spelling
  14. %H
  15. %H  Revision 3.7  1993/02/18  09:19:03  felsch
  16. %H  example fixed
  17. %H
  18. %H  Revision 3.6  1993/02/11  12:20:47  martin
  19. %H  changed reference "Strings" to "Strings and Characters"
  20. %H
  21. %H  Revision 3.5  1993/02/10  20:49:08  martin
  22. %H  fixed some typos
  23. %H
  24. %H  Revision 3.4  1992/04/02  15:43:12  martin
  25. %H  replaced 'Linelength' by 'SizeScreen'
  26. %H
  27. %H  Revision 3.3  1992/03/12  16:18:31  martin
  28. %H  fixed several typos
  29. %H
  30. %H  Revision 3.2  1992/01/23  13:44:51  martin
  31. %H  added 'LogTo' and 'Linelength'
  32. %H
  33. %H  Revision 3.1  1992/01/11  18:32:46  martin
  34. %H  changed the sections 'Help' and 'Reading Sections' to fit on one screen
  35. %H
  36. %H  Revision 3.0  1991/12/27  16:10:27  martin
  37. %H  initial revision under RCS
  38. %H
  39. %%
  40. \Chapter{Environment}
  41.  
  42. This  chapter describes the  interactive  environment in  which  you  use
  43. {\GAP}.
  44.  
  45. The first sections describe  the main read  eval print loop and the break
  46. loop (see "Main Loop", "Break Loops", and "Error").
  47.  
  48. The next section describes the commands you  can use to edit  the current
  49. input line (see "Line Editing").
  50.  
  51. The next sections describe the {\GAP} help  system (see  "Help", "Reading
  52. Sections",  "Format of Sections",    "Browsing through   the   Sections",
  53. "Redisplaying a Section", "Abbreviating Section Names", "Help Index").
  54.  
  55. The next sections describe  the  input  and output functions (see "Read",
  56. "ReadLib", "Print", "PrintTo", "AppendTo", "LogTo", and "SizeScreen").
  57.  
  58. The  next  sections describe  the  functions that  allow you to   collect
  59. statistics about a computation (see "Runtime", "Profile").
  60.  
  61. The last sections describe the functions that allow  you to execute other
  62. programs as subprocesses from within {\GAP} (see "Exec" and "Edit").
  63.  
  64. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  65. \Section{Main Loop}%
  66. \index{read eval print loop}\index{loop!read eval print}%
  67. \index{prompt}\index{prompt!partial}%
  68. \index{syntax errors}\index{errors!syntax}%
  69. \index{output!suppressing}%
  70. \index{last}\index{previous result}%
  71.  
  72. The normal  interaction with {\GAP} happens in  the so--called *read eval
  73. print* loop.  This means that you type an input, {\GAP}  first reads  it,
  74. evaluates it, and prints the result.  The exact sequence is as follows.
  75.  
  76. To show you that  it is ready  to accept your  input, {\GAP} displays the
  77. *prompt* 'gap> '.  When you see this, you know that {\GAP} is waiting for
  78. your input.
  79.  
  80. Note that every statement must be terminated by a  semicolon.   You  must
  81. also enter <return> before {\GAP} starts to read and evaluate your input.
  82. Because  {\GAP} does not  do anything until  you enter  <return>, you can
  83. edit  your input to fix typos and only when  everything is  correct enter
  84. <return> and have {\GAP}  take a  look at it (see "Line Editing").  It is
  85. also possible to enter several statements as  input on a single line.  Of
  86. course each statement must be terminated by a semicolon.
  87.  
  88. It is absolutely acceptable to enter a single statement on several lines.
  89. When you have entered the beginning of a  statement, but the statement is
  90. not  yet  complete, and  you  enter  <return>, {\GAP}  will  display  the
  91. *partial prompt*   '> '.   When you see   this, you  know that {\GAP}  is
  92. waiting for the rest of the statement.  This happens also when you forget
  93. the semicolon ';' that terminates every {\GAP} statement.
  94.  
  95. When you enter <return>, {\GAP} first checks your  input to see  if it is
  96. syntactically  correct (see chapter  "The Programming  Language"  for the
  97. definition  of syntactically correct).   If it is  not, {\GAP}  prints an
  98. error message of the following form
  99.  
  100. |    gap> 1 * ;
  101.     Syntax error: expression expected
  102.     1 * ;
  103.         ^ |
  104.  
  105. The first line tells you what is wrong about  the input, in this case the
  106. '\*' operator takes  two expressions as  operands, so obviously the right
  107. one is missing.  If the  input came from a  file (see "Read"), this  line
  108. will also contain the filename and the line number.  The second line is a
  109. copy of the input.  And the third  line contains a  caret pointing to the
  110. place in the previous line where {\GAP} realized that something is wrong.
  111. This need not be  the exact place where  the error is,  but it is usually
  112. quite close.
  113.  
  114. Sometimes, you will also  see a partial prompt after  you have entered an
  115. input  that is  syntactically incorrect.   This is  because  {\GAP} is so
  116. confused by your  input, that it thinks that  there is still something to
  117. follow.  In this case you  should enter ';<return>' repeatedly,  ignoring
  118. further error messages,  until you see the full  prompt  again.  When you
  119. see the full prompt, you know that {\GAP} forgave you and is now ready to
  120. accept your next -- hopefully correct -- input.
  121.  
  122. If your input is syntactically correct, {\GAP} evaluates  or executes it,
  123. i.e., performs the  required computations  (see chapter "The  Programming
  124. Language" for the definition of the evaluation).
  125.  
  126. If you do not see a prompt, you know that {\GAP} is still working on your
  127. last input.   Of  course,  you  can  *type ahead*,   i.e., already  start
  128. entering new input, but it  will not be  accepted by {\GAP} until  {\GAP}
  129. has completed the ongoing computation.
  130.  
  131. When {\GAP} is ready it will usually print the result of the computation,
  132. i.e., the value computed.  Note that not  all statements produce a value,
  133. for example, if you enter a 'for'  loop, nothing will be printed, because
  134. the 'for' loop does not produce a value that could be printed.
  135.  
  136. Also  sometimes you do  not want to see the   result.  For example if you
  137. have  computed a value and now  want to assign the  result to a variable,
  138. you  probably do not   want to see the   value again.  You  can terminate
  139. statements by *two* semicolons to suppress the printing of the result.
  140.  
  141. If you have entered several statements on a single line {\GAP} will first
  142. read, evaluate, and  print the first one,  then read evaluate, and  print
  143. the second one, and so on.  This means that the second statement will not
  144. even be checked  for  syntactical correctness until {\GAP}  has completed
  145. the first computation.
  146.  
  147. After the result has been printed {\GAP} will display another prompt, and
  148. wait for your next input.  And  the whole process  starts all over again.
  149. Note that a  new  prompt will  only  be  printed after  {\GAP} has  read,
  150. evaluated, and printed the  last  statement if  you have entered  several
  151. statements on a single line.
  152.  
  153. In each statement  that you  enter the  result of  the previous statement
  154. that produced  a value is available in  the variable 'last'.  The next to
  155. previous result is available in  'last2' and  the result produced  before
  156. that is available in 'last3'.
  157.  
  158. |    gap> 1; 2; 3;
  159.     1
  160.     2
  161.     3
  162.     gap> last3 + last2 * last;
  163.     7 |
  164.  
  165. Also in each statement the time spent by the  last  statement, whether it
  166. produced a value or not, is available in the variable 'time'.  This is an
  167. integer that holds the number of milliseconds.
  168.  
  169. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  170. \Section{Break Loops}%
  171.  
  172. When  an  error  has  occurred  or when you  interrupt {\GAP}, usually by
  173. hitting <ctr>-'C', {\GAP} enters a break loop,  that is in most  respects
  174. like the main read  eval print loop  (see "Main Loop").  That is, you can
  175. enter  statements,  {\GAP} reads  them, evaluates  them,  and prints  the
  176. result if  any.  However those  evaluations  happen within the context in
  177. which the error  occurred.   So you can look at the  arguments and  local
  178. variables of the functions that were active  when the error happened  and
  179. even change  them.   The  prompt is changed  from 'gap> ' to  'brk>  ' to
  180. indicate that you are in a break loop.
  181.  
  182. There are two ways to leave a break loop.
  183.  
  184. The first is to quit the break loop and continue in the main loop.  To do
  185. this  you enter 'quit;'  or hit the <eof>  (*e*nd *o*f *f*ile) character,
  186. which is usually <ctr>-'D'.   In this  case  control returns to  the main
  187. loop, and you can enter new statements.
  188.  
  189. The other way is  to return  from a  break loop.  To  do this  you  enter
  190. 'return;' or 'return <expr>;'.  If the break loop was entered because you
  191. interrupted {\GAP}, then you can continue by entering  'return;'.  If the
  192. break loop was  entered due to  an error, you  usually have  to  return a
  193. value to continue the computation.   For example,  if the break  loop was
  194. entered because a  variable  had no assigned  value, you  must return the
  195. value that this variable should have to continue the computation.
  196.  
  197. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  198. \Section{Error}%
  199.  
  200. 'Error( <messages>... )'
  201.  
  202. 'Error' signals  an  error.  First  the messages <messages> are  printed,
  203. this  is done exactly as if 'Print' (see "Print") were  called with these
  204. arguments.  Then a break loop (see "Break Loops") is  entered, unless the
  205. standard error output is not connected to a terminal.  You can leave this
  206. break  loop  with 'return;'  to  continue execution  with  the  statement
  207. following the call to 'Error'.
  208.  
  209. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  210. \Section{Line Editing}%
  211.  
  212. {\GAP} allows you to edit the current input line with a number of editing
  213. commands.  Those commands  are accessible either as  *control keys* or as
  214. *escape keys*.  You enter a control key  by  pressing the <ctr> key, and,
  215. while still holding the <ctr> key  down, hitting another  key <key>.  You
  216. enter an escape key by hitting <esc> and then hitting  another key <key>.
  217. Below   we denote control  keys   by  <ctr>-<key>  and  escape  keys   by
  218. <esc>-<key>.  The case  of <key>  does   not matter, i.e., <ctr>-'A'  and
  219. <ctr>-'a' are equivalent.
  220.  
  221. Characters  not mentioned below always  insert  themselves at the current
  222. cursor position.
  223.  
  224. The first few commands allow you to move the cursor on the current line.
  225.  
  226. <ctr>-'A'       move the cursor to the beginning of the line. \\
  227. <esc>-'B'       move the cursor to the beginning of the previous word. \\
  228. <ctr>-'B'       move the cursor backward one character. \\
  229. <ctr>-'F'       move the cursor forward  one character. \\
  230. <esc>-'F'       move the cursor to the end of the next word. \\
  231. <ctr>-'E'       move the cursor to the end of the line.
  232.  
  233. The next commands delete or  kill  text.  The  last killed   text can  be
  234. reinserted, possibly at a different position with the yank command.
  235.  
  236. <ctr>-'H' or <del> delete the character left of the cursor. \\
  237. <ctr>-'D'       delete the character under the cursor. \\
  238. <ctr>-'K'       kill up to the end of the line. \\
  239. <esc>-'D'       kill forward to the end of the next word. \\
  240. <esc>-<del>     kill backward to the beginning of the last word. \\
  241. <ctr>-'X'       kill entire input line, and discard all pending input. \\
  242. <ctr>-'Y'       insert (yank) a just killed text.
  243.  
  244. The next commands allow you to change the input.
  245.  
  246. <ctr>-'T'       exchange (twiddle) current and previous character. \\
  247. <esc>-'U'       uppercase next word. \\
  248. <esc>-'L'       lowercase next word. \\
  249. <esc>-'C'       capitalize next word.
  250.  
  251. The <tab> character, which is in fact the control key <ctr>-'I', looks at
  252. the characters before the cursor, interprets them as the  beginning of an
  253. identifier and  tries to complete this identifier.  If there is more than
  254. one possible completion, it completes to the longest common prefix of all
  255. those completions.   If  the  characters  to the  left  of the cursor are
  256. already  the longest  common  prefix of all completions  hitting <tab>  a
  257. second time will display all possible completions.
  258.  
  259. <tab>           complete the identifier before the cursor.
  260.  
  261. The next  commands allow  you to fetch  previous lines, e.g.,  to correct
  262. typos, etc.  This history is limited to about 8000 characters.
  263.  
  264. <ctr>-'L'       insert last input line before current character.\\
  265. <ctr>-'P'       redisplay  the last input   line, another  <ctr>-'P' will
  266.                 redisplay the line  before that, etc.   If  the cursor is
  267.                 not in the first column  only the lines starting with the
  268.                 string to the left  of the cursor  are taken.\\
  269. <ctr>-'N'       Like <ctr>-'P' but goes the other way round  through  the
  270.                 history.\\
  271. <esc>-'\<'      goes to the beginning of the history.\\
  272. <esc>-'>'       goes to the end of the history.\\
  273. <ctr>-'O'       accepts this line and perform a <ctr>-'N'.
  274.  
  275. Finally there are a few miscellaneous commands.
  276.  
  277. <ctr>-'V'       enter next character literally, i.e., enter it even if it
  278.                 is one of the control keys.\\
  279. <ctr>-'U'       execute the next command 4 times.\\
  280. <esc>-<num>     execute the next command <num> times.\\
  281. <esc>-<ctr>-'L'  repaint input line.
  282.  
  283. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  284. \Section{Help}%
  285.  
  286. This  section describes  together with  the following sections the {\GAP}
  287. help system.  The help system lets you read the manual interactively.
  288.  
  289. '?<section>'
  290.  
  291. The help command '?' displays the section  with the name <section> on the
  292. screen.  For  example '?Help'  will display this   section on the screen.
  293. You should not  type in  the single quotes,   they are only  used in help
  294. sections to delimit text that you should enter into {\GAP} or that {\GAP}
  295. prints in response.  When the whole section has been displayed the normal
  296. {\GAP} prompt 'gap>' is shown and normal {\GAP} interaction resumes.
  297.  
  298. The section "Reading  Sections"  tells  you what actions  you can perform
  299. while  you are reading  a  section.   You  command {\GAP} to display this
  300. section  by  entering '?Reading Sections', without quotes.   The  section
  301. "Format of Sections" describes the format of sections and the conventions
  302. used, "Browsing through the  Sections" lists the commands you use to flip
  303. through  sections, "Redisplaying  a  Section" describes  how  to  read  a
  304. section again, "Abbreviating Section Names" tells you how to avoid typing
  305. the long section names, and "Help Index" describes the the index command.
  306.  
  307. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  308. \Section{Reading Sections}%
  309. \index{help!scrolling}
  310.  
  311. If the  section is longer than 24  lines {\GAP} stops  after 24 lines and
  312. displays
  313.  
  314. |    -- <space> for more --|
  315.  
  316. If you press <space> {\GAP} displays the next 24 lines of the section and
  317. then stops again.   This  goes on   until  the whole   section  has  been
  318. displayed, at which  point {\GAP}  will  return immediately to  the  main
  319. {\GAP} loop.  Pressing 'f' has the same effect as <space>.
  320.  
  321. You can also press 'b' or the key labeled <del> which will scroll back to
  322. the *previous* 24 lines of  the section.  If  you press 'b' or <del> when
  323. {\GAP} is displaying the top of a section {\GAP} will ring the bell.
  324.  
  325. You can  also press 'q'  to quit and  return immediately back to the main
  326. {\GAP} loop without reading the rest of the section.
  327.  
  328. Actually the 24 is only a default,  if you have a larger screen  that can
  329. display more lines of text you  may want to tell this to {\GAP} with  the
  330. '-y <rows>' option when you start {\GAP}.
  331.  
  332. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  333. \Section{Format of Sections}%
  334. \index{help!format}
  335.  
  336. This section describes the format of sections when they are displayed  on
  337. the screen and the special conventions used.
  338.  
  339. As you can see {\GAP} indents sections 4 spaces and  prints a header line
  340. containing  the  name of the  section  on the  left and  the  name of the
  341. chapter on the right.
  342.  
  343. |<text>|
  344.  
  345. Text enclosed in angle brackets is used for arguments in the descriptions
  346. of  functions and for other placeholders.   It  means that you should not
  347. actually  enter this text into  {\GAP} but replace   it by an appropriate
  348. text depending on what you  want to do.   For example when we write  that
  349. you should enter '?<section>' to see the section with the name <section>,
  350. <section> servers as  a placeholder, indicating  that  you can enter  the
  351. name of the section that you want to  see at this  place.  In the printed
  352. manual such text is printed in italics.
  353.  
  354. |'text'|
  355.  
  356. Text  enclosed  in single  quotes  is used  for  names of  variables  and
  357. functions and other  text that you may actually enter into  your computer
  358. and see on  your  screen.  The text enclosed in single quotes may contain
  359. placeholders enclosed in angle brackets as described above.   For example
  360. when the  help  text  for 'IsPrime'  says  that the form of  the  call is
  361. |'IsPrime( <n> )'| this means that you should actually enter the IsPrime(
  362. and  ),  without the  quotes,  but  replace the  <n> with the  number (or
  363. expression) that  you  want  to test.  In the printed manual this text is
  364. printed in a monospaced  (all characters have  the same width) typewriter
  365. font.
  366.  
  367. |"text"|
  368.  
  369. Text enclosed  in  double  quotes  is  used for cross references to other
  370. parts of the manual.  So the text inside the double quotes is the name of
  371. another  section of  the manual.  This is  used  to  direct you  to other
  372. sections that describe a topic or  a  function used  in this section.  So
  373. for example "Abbreviating Section Names" is a cross reference to the next
  374. section.  In the printed manual the text is replaced by the number of the
  375. section.
  376.  
  377. |_| and |^|
  378.  
  379. In mathematical formulas the underscore and  the caret are used to denote
  380. subscription  and superscription.  Ordinarily they apply only to the very
  381. next  character  following,   unless  a   whole  expression  enclosed  in
  382. parentheses follows.  So for example |x_1^(i+1)| denotes the variable 'x'
  383. with  subscript  1 raised  to the  'i+1'  power.  In  the  printed manual
  384. mathematical  formulas are typeset in italics (actually mathitalics)  and
  385. subscripts and superscripts are actually lowered and raised.
  386.  
  387. Longer examples are usually  paragraphs of their  own that are indented 8
  388. spaces from the left margin, i.e.  4 spaces further than  the surrounding
  389. text.  Everything  on the lines with  the prompts 'gap>' and '>',  except
  390. the  prompts  themselves  of course,  is the  input  you  have  to  type,
  391. everything else is {\GAP}\'s response.   In the printed  manual  examples
  392. are also indented 4 spaces  and are  printed  in  a monospaced typewriter
  393. font.
  394.  
  395. |    gap> ?Format of Sections
  396.     Format of Sections ______________________________________ Environment
  397.  
  398.     This section describes the format of sections when they are displayed
  399.     on the screen and the special conventions used.
  400.  
  401.     ... |
  402.  
  403. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  404. \Section{Browsing through the Sections}%
  405. \index{help!browsing}
  406.  
  407. The help  sections are organized like  a book into chapters.  This should
  408. not  surprise you, since   the same source  is used  both for the printed
  409. manual and the online help.  Just as you can flip  through the pages of a
  410. book there are special commands to browse through the help sections.
  411.  
  412. '?>' \\
  413. '?\<'
  414.  
  415. The two help commands '?\<' and '?>' correspond to the flipping of pages.
  416. '?\<' takes you to the section preceding the current section and displays
  417. it, and '?>' takes you to the section following the current section.
  418.  
  419. '?\<\<' \\
  420. '?>>'
  421.  
  422. '?\<\<' is like '?\<',  only  more so.  It   takes you back to  the first
  423. section of the current  chapter, which gives an  overview of the sections
  424. described in  this chapter.  If you  are already in  this section '?\<\<'
  425. takes you to the first section of  the previous chapter.  '?>>' takes you
  426. to the first section of the next chapter.
  427.  
  428. '?-'\\
  429. '?+'
  430.  
  431. {\GAP} remembers the sections that you have read.  '?-'  takes you to the
  432. one that you  have read before  the  current one, and  displays it again.
  433. Further '?-' takes you further back  in this history.  '?+' reverses this
  434. process, i.e.,  it  takes you  back to   the section that   you have read
  435. *after* the current one.  It is important to  note, that '?-' and '?+' do
  436. *not* alter the history like the other help commands.
  437.  
  438. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  439. \Section{Redisplaying a Section}%
  440. \index{help!redisplaying}
  441.  
  442. '?'
  443.  
  444. The help command '?' followed by no section name redisplays the last help
  445. section again.  So  if you  reach  the bottom of  a long help section and
  446. already forgot what  was mentioned at the beginning, or, for example, the
  447. examples  do  not  seem  to  agree  with  your   interpretation  of   the
  448. explanations, use '?' to read the whole section again from the beginning.
  449.  
  450. When  '?' is used before any section  has  been read {\GAP}  displays the
  451. section 'Welcome to GAP'.
  452.  
  453. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  454. \Section{Abbreviating Section Names}%
  455. \index{help!abbreviating}
  456.  
  457. Upper and lower case in <section> are not distinguished, so typing either
  458. '?Abbreviating Section Names' or '?abbreviating section names' will  show
  459. this very section.
  460.  
  461. Each  word  in  <section>  may be  abbreviated.   So  instead  of  typing
  462. '?abbreviating section names'  you may also type '?abb sec nam',  or even
  463. '?a s n'.  You  must not omit the spaces separating  the words.  For each
  464. word in the section name you must  give at least the first character.  As
  465. another example you may  type '?oper for int' instead of '?operations for
  466. integers', which is especially handy when you can not remember whether it
  467. was 'operations' or 'operators'.
  468.  
  469. If an abbreviation matches multiple   section names a   list of all these
  470. section names is displayed.
  471.  
  472. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  473. \Section{Help Index}%
  474. \index{help!index}
  475.  
  476. '??<topic>'
  477.  
  478. '??' looks up <topic> in {\GAP}\'s index and prints all the index entries
  479. that contain the substring <topic>.  Then you can decide which section is
  480. the one you are actually interested in and request this one.
  481.  
  482. |    gap> ??help
  483.         help ______________________________________________________ Index
  484.         Help
  485.         Reading Sections (help!scrolling)
  486.         Format of the Sections (help!format)
  487.         Browsing through the Sections (help!browsing)
  488.         Redisplaying a Section (help!redisplaying)
  489.         Abbreviating Section Names (help!abbreviating)
  490.         Help Index
  491.     gap> |
  492.  
  493. The first thing on each line is the name of the  section.  If the name of
  494. the section matches <topic> nothing more is printed.  Otherwise the index
  495. entry  that matched   <topic>  is printed   in  parentheses following the
  496. section name.  For  each section only  the first matching index entry  is
  497. printed.  The  order  of the sections corresponds  to  their order in the
  498. {\GAP} manual, so that related sections should be adjacent.
  499.  
  500. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  501. \Section{Read}%
  502. \index{read!a file}\index{load!a file}%
  503. \index{file!read a}\index{file!load a}
  504.  
  505. 'Read( <filename> )'
  506.  
  507. 'Read' reads the input from the  file with the filename <filename>, which
  508. must be a string.
  509.  
  510. 'Read' first opens the file <filename>.   If the file  does not exist, or
  511. if {\GAP} can not open it, e.g., because of access restrictions, an error
  512. is signalled.
  513.  
  514. Then the contents of the file are read and evaluated, but the results are
  515. not printed.  The  reading and printing happens exactly  as described for
  516. the main loop (see "Main Loop").
  517.  
  518. If an   input in  the file contains   a syntactical  error, a message  is
  519. printed, and the rest of  this statement is ignored,  but the rest of the
  520. file is read.
  521.  
  522. If a statement in the file  causes an error  a break loop is entered (see
  523. "Break Loops").   The  input for this break  loop  is not taken  from the
  524. file, but from the input connected to the 'stderr'  output of {\GAP}.  If
  525. 'stderr'  is not connected to  a terminal, no  break loop is entered.  If
  526. this break loop is left with 'quit' (or <ctr>-'D') the file is closed and
  527. {\GAP} does not continue to read from it.
  528.  
  529. Note that a statement may not begin in one file and end in another, i.e.,
  530. <eof> (*e*nd *o*f *f*ile) is not treated as  whitespace, but as a special
  531. symbol that must not appear inside any statement.
  532.  
  533. Note that one file may very well contain a read statement causing another
  534. file to  be read, before input is again taken from the first file.  There
  535. is an operating  system dependent maximum on the number of files that may
  536. be open at once, usually it is 15.
  537.  
  538. The special  file name '\"\*stdin\*\"'  denotes the standard input, i.e.,
  539. the stream through  which the user  enters commands to {\GAP}.  The exact
  540. behaviour of  'Read( \"\*stdin\*\" )'  is operating system dependent, but
  541. usually  the  following happens.   If {\GAP}   was started  with no input
  542. redirection, statements are read from  the terminal stream until the user
  543. enters the end of file character,  which is usually <ctr>-'D'.  Note that
  544. terminal  streams are special,  in that  they  may  yield ordinary  input
  545. *after* an end of file.  Thus when control returns to the main read eval
  546. print loop the user can continue with {\GAP}.  If {\GAP} was started with
  547. an input  redirection, statements are read  from the current  position in
  548. the input file up  to the end of the  file.  When control returns  to the
  549. main read eval print loop the input stream will still return end of file,
  550. and {\GAP} will terminate.  The special file name '\"\*errin\*\"' denotes
  551. the stream  connected with the 'stderr' output.   This stream  is usually
  552. connected  to the terminal,  even if  the standard  input was redirected,
  553. unless  the  standard error  stream was  also  redirected, in  which case
  554. opening of '\"\*errin\*\"' fails, and 'Read' will signal an error.
  555.  
  556. 'Read'  is implemented  in  terms of the  function 'READ', which  behaves
  557. exactly like 'Read', except that 'READ' does not signal an  error when it
  558. can not open  the file.  Instead it returns 'true' or 'false' to indicate
  559. whether opening the file was successful or not.
  560.  
  561. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  562. \Section{ReadLib}%
  563. \index{read!a library file}\index{load!a library file}%
  564. \index{file!read a library}\index{file!load a library}
  565.  
  566. 'ReadLib( <name> )'
  567.  
  568. 'ReadLib'  reads   input from  the  library  file  with  the name <name>.
  569. 'ReadLib' prefixes  <name> with the value of  the variable  'LIBNAME' and
  570. appends the string '\".g\"' and calls 'Read'  (see "Read") with this file
  571. name.
  572.  
  573. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  574. \Section{Print}%
  575.  
  576. 'Print( <obj1>, <obj2>... )'
  577.  
  578. 'Print' prints the objects <obj1>, <obj2>... etc. to the standard output.
  579. The output looks exactly like  the printed  representation of the objects
  580. printed by the main loop.  The exception are strings,  which are  printed
  581. without  the enclosing  quotes  and  a  few  other  transformations  (see
  582. "Strings  and Characters").   Note that  no  space  or newline is printed
  583. between  the  objects.  'PrintTo'  can  be used  to print to a  file (see
  584. "PrintTo").
  585.  
  586. |    gap> for i  in [1..5]  do
  587.     >     Print( i, " ", i^2, " ", i^3, "\n" );
  588.     > od;
  589.     1 1 1
  590.     2 4 8
  591.     3 9 27
  592.     4 16 64
  593.     5 25 125 |
  594.  
  595. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  596. \Section{PrintTo}%
  597. \index{print!to a file}%
  598. \index{file!print to a}
  599.  
  600. 'PrintTo( <filename>, <obj1>, <obj2>... )'
  601.  
  602. 'PrintTo' works  like  'Print', except that  the output is printed to the
  603. file with the name <filename> instead of the  standard output.  This file
  604. must of  course be writable by {\GAP},  otherwise  an error is signalled.
  605. Note that 'PrintTo' will overwrite the previous contents  of this file if
  606. it  already existed.  'AppendTo' can be used  to append  to  a file  (see
  607. "AppendTo").
  608.  
  609. The  special  file  name  '\"\*stdout\*\"' can  be  used to print  to the
  610. standard output.   This is equivalent to a  plain 'Print', except  that a
  611. plain  'Print'  that is  executed  while   evaluating an argument    to a
  612. 'PrintTo' call will  also  print to  the output  file opened by  the last
  613. 'PrintTo'  call,  while  'PrintTo(  \"\*stdout\*\", <obj1>,  <obj2>... )'
  614. always   prints to     the standard output.    The  special   file   name
  615. '\"\*errout\*\"' can be used to print to the standard error  output file,
  616. which is usually connected with the terminal, even if the standard output
  617. was redirected.
  618.  
  619. There is an  operating  system dependent maximum to the number  of output
  620. files that may be open at once, usually this is 14.
  621.  
  622. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  623. \Section{AppendTo}%
  624. \index{append!to a file}%
  625. \index{file!append to a}
  626.  
  627. 'AppendTo( <filename>, <obj1>, <obj2>... )'
  628.  
  629. 'AppendTo' works like  'PrintTo'  (see "PrintTo"), except that the output
  630. does not overwrite the previous contents of the  file, but is appended to
  631. the file.
  632.  
  633. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  634. \Section{LogTo}%
  635. \index{log!to a file}%
  636. \index{file!log to a}
  637.  
  638. 'LogTo( <filename> )'
  639.  
  640. 'LogTo' causes  the subsequent interaction to be  logged to the file with
  641. the name <filename>, i.e., everything you see on  your terminal will also
  642. appear in  this  file.  This file must  of course be  writable by {\GAP},
  643. otherwise an error is signalled.   Note that 'PrintTo' will overwrite the
  644. previous contents of this file if it already existed.
  645.  
  646. 'LogTo()'
  647.  
  648. In this form 'LogTo' stops logging again.
  649.  
  650. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  651. \Section{SizeScreen}%
  652.  
  653. 'SizeScreen()'
  654.  
  655. In this form 'ScreeSize' returns the size of the screen as  a  list  with
  656. two entries.  The first is the length of each line,  the  second  is  the
  657. number of lines.
  658.  
  659. 'SizeScreen( [ <x>, <y> ] )'
  660.  
  661. In this form 'SizeScreen' sets the size of the screen.  <x> is the length
  662. of  each line, <y> is the number of  lines.  Either value may be missing,
  663. to leave  this value unaffected.  Note that those parameters can  also be
  664. set with the command line options '-x <x>' and '-y <y>' (see "Getting and
  665. Installing GAP").
  666.  
  667. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  668. \Section{Runtime}%
  669.  
  670. 'Runtime()'
  671.  
  672. 'Runtime' returns the time spent by {\GAP} in milliseconds as an integer.
  673. This is usually the cpu time,  i.e., not the  wall clock time.  Also time
  674. spent by subprocesses of {\GAP} (see "Exec") is not counted.
  675.  
  676. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  677. \Section{Profile}%
  678.  
  679. 'Profile( true )'
  680.  
  681. In this form 'Profile' turns  the  profiling on.  Subsequent computations
  682. will record the time spent by each function and the number of  times each
  683. function was called.  Old profiling information is cleared.
  684.  
  685. 'Profile( false )'
  686.  
  687. In  this   form 'Profile' turns    the  profiling off  again.    Recorded
  688. information is still kept, so you can  display it even  after turning the
  689. profiling off.
  690.  
  691. 'Profile()'
  692.  
  693. In   this  form 'Profile'  displays  the  collected  information   in the
  694. following format.
  695.  
  696. |    gap> Factors( 10^21+1 );;    # make sure that the library is loaded
  697.     gap> Profile( true );
  698.     gap> Factors( 10^42+1 );
  699.     [ 29, 101, 281, 9901, 226549, 121499449, 4458192223320340849 ]
  700.     gap> Profile( false );
  701.     gap> Profile();
  702.      count    time percent time/call child function
  703.          4    1811      76     452    2324  FactorsRho
  704.         18     171       7       9     237  PowerModInt
  705.        127      94       3       0      94  GcdInt
  706.         41      83       3       2     415  IsPrimeInt
  707.         91      59       2       0      59  TraceModQF
  708.        511      47       1       0      39  QuoInt
  709.         22      23       0       1      23  Jacobi
  710.        116      20       0       0      31  log
  711.          3      20       0       6      70  SmallestRootInt
  712.          1      19       0      19    2370  FactorsInt
  713.         26      15       0       0      39  LogInt
  714.          4       4       0       1       4  Concatenation
  715.          5       4       0       0      20  RootInt
  716.          7       0       0       0       0  Add
  717.         26       0       0       0       0  Length
  718.         13       0       0       0       0  NextPrimeInt
  719.          4       0       0       0       0  AddSet
  720.          4       0       0       0       0  IsList
  721.          4       0       0       0       0  Sort
  722.          8       0       0       0       0  Append
  723.               2369     100                  TOTAL |
  724.  
  725. The last  column contains the  name  of the function.   The  first column
  726. contains the number of times each function was called.  The second column
  727. contains the time spent in this function.  The third column  contains the
  728. percentage of the total  time spent in this  function.  The fourth column
  729. contains the time per call, i.e., the quotient of the second by the first
  730. number.  The fifth column  contains the time  spent  in this function and
  731. all other functions called, directly or indirectly, by this function.
  732.  
  733. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  734. \Section{Exec}%
  735.  
  736. 'Exec( <command> )'
  737.  
  738. 'Exec'  executes  the  command  given by  the  string <command>   in  the
  739. operating system.  How this happens is operating system dependent.  Under
  740. UNIX, for example, a new  shell is started  and <command>  is passed as a
  741. command to this shell.
  742.  
  743. |    gap> Exec( "date" );
  744.     Fri Dec 13 17:00:29 MET 1991 |
  745.  
  746. 'Edit' (see "Edit") should be used to call an editor from within {\GAP}.
  747.  
  748. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  749. \Section{Edit}%
  750.  
  751. 'Edit( <filename> )'
  752.  
  753. 'Edit' starts  an editor  with the  file whose filename is  given by  the
  754. string <filename>, and reads the file back into {\GAP}  when you exit the
  755. editor again.   You should set the  variable  'EDITOR' to the name of the
  756. editor  that you usually  use, e.g., '/usr/ucb/vi'.  This can for example
  757. be done  in  your  '.gaprc'  file (see  the sections  on operating system
  758. dependent features in chapter "Getting and Installing GAP").
  759.  
  760. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  761. %%
  762. %E  Emacs . . . . . . . . . . . . . . . . . . . . . local Emacs variables
  763. %%
  764. %%  Local Variables:
  765. %%  mode:               outline
  766. %%  outline-regexp:     "\\\\Chapter\\|\\\\Section"
  767. %%  fill-column:        73
  768. %%  eval:               (hide-body)
  769. %%  End:
  770. %%
  771.  
  772.  
  773.  
  774.