PageRenderTime 62ms CodeModel.GetById 32ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/tigcc/doc/System/WebFiles/error.html

http://github.com/debrouxl/gcc4ti
HTML | 417 lines | 358 code | 43 blank | 16 comment | 0 complexity | ac5a5899c2134b7a7fa1236fe3970ac2 MD5 | raw file
Possible License(s): GPL-2.0, AGPL-1.0
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <HTML>
  3. <HEAD>
  4. <TITLE>error.h</TITLE>
  5. <STYLE TYPE="TEXT/CSS">
  6. <!--
  7. .IE3-DUMMY { CONT-SIZE: 100%; }
  8. BODY { FONT-FAMILY: Verdana,Arial,Helvetica,Sans-Serif; BACKGROUND-COLOR: #E0E0E0; }
  9. P { FONT-FAMILY: Verdana,Arial,Helvetica,Sans-Serif; }
  10. H1 { FONT-FAMILY: Verdana,Arial,Helvetica,Sans-Serif; }
  11. H2 { FONT-FAMILY: Verdana,Arial,Helvetica,Sans-Serif; }
  12. H3 { FONT-FAMILY: Verdana,Arial,Helvetica,Sans-Serif; }
  13. H4 { FONT-FAMILY: Verdana,Arial,Helvetica,Sans-Serif; }
  14. H5 { FONT-FAMILY: Verdana,Arial,Helvetica,Sans-Serif; }
  15. H6 { FONT-FAMILY: Verdana,Arial,Helvetica,Sans-Serif; }
  16. UL { FONT-FAMILY: Verdana,Arial,Helvetica,Sans-Serif; }
  17. TD { FONT-FAMILY: Verdana,Arial,Helvetica,Sans-Serif; BACKGROUND-COLOR: #FFFFFF; }
  18. .NOBORDER { BACKGROUND-COLOR: #E0E0E0; PADDING: 0pt; }
  19. .NOBORDER TD { FONT-FAMILY: Verdana,Arial,Helvetica,Sans-Serif; BACKGROUND-COLOR: #E0E0E0; PADDING: 0pt; }
  20. .CODE { FONT-FAMILY: Courier New; }
  21. -->
  22. </STYLE>
  23. </HEAD>
  24. <BODY TEXT="#000000" BGCOLOR="#E0E0E0">
  25. <FONT SIZE="5"><B>The &lt;error.h&gt; Header File</B></FONT>
  26. <HR>
  27. <P><B>Routines for error handling</B></P>
  28. <H3><U>Language Extensions</U></H3>
  29. <DL INDENT="20"><DT><B><A HREF="#ENDFINAL">ENDFINAL</A></B><DD>Terminates a TRY...FINALLY...ENDFINAL block.<IMG WIDTH="1" HEIGHT="20" ALIGN="TOP"><DT><B><A HREF="#ENDTRY">ENDTRY</A></B><DD>Terminates a TRY...ONERR...ENDTRY block.<IMG WIDTH="1" HEIGHT="20" ALIGN="TOP"><DT><B><A HREF="#FINALLY">FINALLY</A></B><DD>Begins the termination handler in a TRY...FINALLY...ENDFINAL block.<IMG WIDTH="1" HEIGHT="20" ALIGN="TOP"><DT><B><A HREF="#ONERR">ONERR</A></B><DD>Begins the error handler in a TRY...ONERR...ENDTRY block.<IMG WIDTH="1" HEIGHT="20" ALIGN="TOP"><DT><B><A HREF="#PASS">PASS</A></B><DD>Passes on unhandled errors to a higher level.<IMG WIDTH="1" HEIGHT="20" ALIGN="TOP"><DT><B><A HREF="#TRY">TRY</A></B><DD>Starts a protected block of code.</DL>
  30. <H3><U>Functions</U></H3>
  31. <DL INDENT="20"><DT><B><A HREF="#ER_catch">ER_catch</A></B><DD>Catches an error.<IMG WIDTH="1" HEIGHT="20" ALIGN="TOP"><DT><B><A HREF="#ER_success">ER_success</A></B><DD>Pops the state from the error stack.<IMG WIDTH="1" HEIGHT="20" ALIGN="TOP"><DT><B><A HREF="#ER_throw">ER_throw</A></B><DD>Throws an error with a constant number.<IMG WIDTH="1" HEIGHT="20" ALIGN="TOP"><DT><B><A HREF="#ER_throwVar">ER_throwVar</A></B><DD>Throws an error.<IMG WIDTH="1" HEIGHT="20" ALIGN="TOP"><DT><B><A HREF="#ERD_dialog">ERD_dialog</A></B><DD>Displays an error dialog box.<IMG WIDTH="1" HEIGHT="20" ALIGN="TOP"><DT><B><A HREF="#ERD_dismissNotice">ERD_dismissNotice</A></B><DD>Removes the error notice displayed by a prior call to <A HREF="#ERD_notice">ERD_notice</A>.<IMG WIDTH="1" HEIGHT="20" ALIGN="TOP"><DT><B><A HREF="#ERD_notice">ERD_notice</A></B><DD>Displays an error notice.<IMG WIDTH="1" HEIGHT="20" ALIGN="TOP"><DT><B><A HREF="#ERD_process">ERD_process</A></B><DD>Processes an error.<IMG WIDTH="1" HEIGHT="20" ALIGN="TOP"><DT><B><A HREF="#find_error_message">find_error_message</A></B><DD>Returns a TI-Basic error message string.</DL>
  32. <H3><U>Global Variables</U></H3>
  33. <DL INDENT="20"><DT><B><A HREF="#errCode">errCode</A></B><DD>Contains the error number in a TRY...ONERR...ENDTRY block.</DL>
  34. <H3><U>Predefined Types</U></H3>
  35. <DL INDENT="20"><DT><B><A HREF="alloc.html#Bool">Bool</A></B><DD>An enumeration to describe true or false values.<IMG WIDTH="1" HEIGHT="20" ALIGN="TOP"><DT><B><A HREF="#ERROR_FRAME">ERROR_FRAME</A></B><DD>A type designed for capturing a task state.<IMG WIDTH="1" HEIGHT="20" ALIGN="TOP"><DT><B><A HREF="#ErrorCodes">ErrorCodes</A></B><DD>An enumeration containing all error codes.</DL>
  36. <HR>
  37. <H3><A NAME="ENDFINAL"><U>ENDFINAL</U></A></H3>
  38. <P><B>Terminates a TRY...FINALLY...ENDFINAL block.</B></P>
  39. <P>The macro ENDFINAL terminates a <A HREF="#TRY">TRY</A>...<A HREF="#FINALLY">FINALLY</A>...ENDFINAL block.
  40. See <A HREF="#TRY">TRY</A> for more info.</P>
  41. <HR>
  42. <H3><A NAME="ENDTRY"><U>ENDTRY</U></A></H3>
  43. <P><B>Terminates a TRY...ONERR...ENDTRY block.</B></P>
  44. <P>The macro ENDTRY terminates a <A HREF="#TRY">TRY</A>...<A HREF="#ONERR">ONERR</A>...ENDTRY block.
  45. See <A HREF="#TRY">TRY</A> for more info.</P>
  46. <HR>
  47. <H3><A NAME="FINALLY"><U>FINALLY</U></A></H3>
  48. <P><B>Begins the termination handler in a TRY...FINALLY...ENDFINAL block.</B></P>
  49. <P>The macro FINALLY ends the protected block and begins the handler for code
  50. which always has to be executed (see <A HREF="#TRY">TRY</A> for more info).
  51. The variable <A HREF="#errCode">errCode</A> is
  52. automatically created in the error handler, and it contains the error number to allow
  53. the program to check what caused the error, or 0 if there was no error.
  54. This variable is destroyed after the <A HREF="#ENDFINAL">ENDFINAL</A> statement.
  55. <BR><BR>
  56. <B>Note:</B> The macro FINALLY uses the <A HREF="#ER_success">ER_success</A> function to end the protected
  57. block, and <A HREF="#ENDFINAL">ENDFINAL</A> uses <A HREF="#PASS">PASS</A> to throw the
  58. error signaled by <A HREF="#errCode">errCode</A> a second time.
  59. <BR><BR>
  60. Here is an example (called "Memory Error"), which demonstrates the use of this
  61. macro:</P>
  62. <PRE>// Allocate memory as long as possible, then throw an error
  63. // All allocated memory will be freed again!
  64. #define USE_TI89 // Compile for TI-89
  65. #define USE_TI92PLUS // Compile for TI-92 Plus
  66. #define USE_V200 // Compile for V200
  67. #define MIN_AMS 100 // Compile for AMS 1.00 or higher
  68. #define ENABLE_ERROR_RETURN // Enable Returning Errors to TIOS
  69. #include &lt;tigcclib.h&gt; // Include All Header Files
  70. #define BLOCK_SIZE 1024
  71. void AllocRecursively(void)
  72. {
  73. void *ptr = malloc_throw (BLOCK_SIZE);
  74. TRY
  75. // Could do something with ptr here...
  76. AllocRecursively ();
  77. // Could still do something with ptr...
  78. FINALLY
  79. free (ptr);
  80. ENDFINAL
  81. }
  82. // Main Function
  83. void _main(void)
  84. {
  85. AllocRecursively ();
  86. }
  87. </PRE>
  88. <HR>
  89. <H3><A NAME="ONERR"><U>ONERR</U></A></H3>
  90. <P><B>Begins the error handler in a TRY...ONERR...ENDTRY block.</B></P>
  91. <P>The macro ONERR ends the protected block and begins the error handler (see
  92. <A HREF="#TRY">TRY</A> for more info). The variable <A HREF="#errCode">errCode</A> is
  93. automatically created in the error handler, and it contains the error number to allow
  94. the program to check what caused the error. This variable
  95. is destroyed after the <A HREF="#ENDTRY">ENDTRY</A> statement.
  96. <BR><BR>
  97. <B>Note:</B> The macro ONERR uses the <A HREF="#ER_success">ER_success</A> function to end the protected
  98. block.</P>
  99. <HR>
  100. <H3><A NAME="PASS"><U>PASS</U></A></H3>
  101. <P><B>Passes on unhandled errors to a higher level.</B></P>
  102. <P>The macro PASS passes on any unhandled errors to a higher level error handler (see
  103. <A HREF="#TRY">TRY</A> for more info). In fact, it executes <A HREF="#ER_throwVar">ER_throwVar</A>
  104. with <A HREF="#errCode">errCode</A> as an argument.</P>
  105. <HR>
  106. <H3><A NAME="TRY"><U>TRY</U></A></H3>
  107. <P><B>Starts a protected block of code.</B></P>
  108. <P>TRY,
  109. <A HREF="#ONERR">ONERR</A>,
  110. <A HREF="#ENDTRY">ENDTRY</A>,
  111. <A HREF="#FINALLY">FINALLY</A>,
  112. <A HREF="#ENDFINAL">ENDFINAL</A>, and
  113. <A HREF="#PASS">PASS</A>
  114. are macros which extend the C language to implement an error handling mechanism which is
  115. almost identical to the commonly-used exception handling as well as error handling in TI-Basic.
  116. <BR><BR>
  117. TRY begins the protected block. It is a macro which is implemented using the
  118. <A HREF="#ER_catch">ER_catch</A> function. If an error occurs in the protected block, program
  119. execution transfers to the block after the <A HREF="#ONERR">ONERR</A> or
  120. <A HREF="#FINALLY">FINALLY</A> statement.
  121. <BR><BR>
  122. However, <A HREF="#ONERR">ONERR</A> and <A HREF="#FINALLY">FINALLY</A>
  123. are entirely different. The <A HREF="#ONERR">ONERR</A> block will not
  124. be executed if there was no error, and it is assumed to either handle the
  125. error or call <A HREF="#PASS">PASS</A>. The error is cleared, so if
  126. <A HREF="#PASS">PASS</A> is not called, the execution continues
  127. normally after the <A HREF="#ENDTRY">ENDTRY</A> statement.
  128. <BR><BR>
  129. <A HREF="#FINALLY">FINALLY</A>, on the other hand, is not implemented
  130. to handle errors, but instead to create a block of code which will always be
  131. executed, regardless of whether there was an error or not. It does not clear
  132. the error (or more precisely, <A HREF="#ENDFINAL">ENDFINAL</A> throws
  133. it again). This can be used in a function which allocates memory, destroys
  134. the contents of the screen, or does something else which always needs cleaning up.
  135. If the function throws an error in a protected block, the memory should
  136. always be freed again, the screen should be restored, etc. But the error
  137. should not be handled at the same time; instead, it must be handled on a
  138. higher level (often even in the calling function).
  139. <BR><BR>
  140. The usage of <A HREF="#ONERR">ONERR</A> is illustrated in the following example:</P>
  141. <PRE>TRY
  142. // <I>&lt;protected code&gt;</I>
  143. ONERR
  144. if (errCode == <I>some_specific_code</I>)
  145. // <I>&lt;error handler&gt;</I>
  146. else
  147. // <I>pass on any unhandled errors to a higher level</I>
  148. PASS;
  149. ENDTRY
  150. </PRE>
  151. <P>The usage of <A HREF="#FINALLY">FINALLY</A> is illustrated in the following example:</P>
  152. <PRE>TRY
  153. ...
  154. // <I>&lt;allocate memory&gt;</I>
  155. TRY
  156. // <I>&lt;protected code&gt;</I>
  157. FINALLY
  158. // <I>&lt;free the allocated memory&gt;</I>
  159. ENDFINAL
  160. ...
  161. ONERR
  162. // <I>&lt;error handler&gt;</I>
  163. ENDTRY
  164. </PRE>
  165. <P>The variable <A HREF="#errCode">errCode</A> is automatically created in the error handler, and
  166. it contains the error number to allow the program to check what caused the error. This variable
  167. will be destroyed after the <A HREF="#ENDTRY">ENDTRY</A>/<A HREF="#ENDFINAL">ENDFINAL</A> statement.
  168. <BR><BR>
  169. It is important to say that you must not exit the protected block using
  170. <A HREF="keywords.html#goto">goto</A> or <A HREF="keywords.html#return">return</A> statements, else the error frame will not
  171. be removed, so the further behavior of the program will be unpredictable.
  172. If you really want to exit from the protected block before its natural end
  173. (i.e. before the <A HREF="#ONERR">ONERR</A> or <A HREF="#FINALLY">FINALLY</A> statement),
  174. call <A HREF="#ER_success">ER_success</A> explicitely to remove the error frame
  175. before exiting, i.e. do something like</P>
  176. <PRE>TRY
  177. ...
  178. if (<I>I_really_must_exit_from_here</I>)
  179. {
  180. ER_success ();
  181. return;
  182. }
  183. ...
  184. ONERR
  185. ...
  186. ENDTRY
  187. </PRE>
  188. <P>But in general this is a very bad practice and should be avoided even if it
  189. requires some extra code. For example, you can rewrite the code like this:</P>
  190. <PRE>TRY
  191. ...
  192. if (!<I>I_really_must_exit_from_here</I>)
  193. {
  194. ...
  195. }
  196. ONERR
  197. ...
  198. ENDTRY
  199. if (<I>I_really_must_exit_from_here</I>)
  200. return;
  201. </PRE>
  202. <P>There is also another possible caveat related to error handling. The TRY macro (or
  203. <A HREF="#ER_catch">ER_catch</A>, more precisely) saves many of
  204. the registers on its execution context stack, since <A HREF="#ER_catch">ER_catch</A> needs to
  205. simulate a return identical to the return of any normal function. Consequently, when an error is thrown, all
  206. variables which reside in registers are reset to their contents before the TRY macro was
  207. called. If code in an <A HREF="#ONERR">ONERR</A> or <A HREF="#FINALLY">FINALLY</A>
  208. block needs the value of a variable set in the TRY block, the code must arrange to make sure
  209. the C code optimizer does not put that variable in a register. This can be
  210. accomplished by declaring such variables to be <A HREF="keywords.html#volatile">volatile</A>.
  211. So, remember this rule: Variables changed in a TRY block must be declared volatile if they
  212. are referenced in an <A HREF="#ONERR">ONERR</A> or <A HREF="#FINALLY">FINALLY</A> block!
  213. <BR><BR>
  214. If you want to protect the whole program, passing all unhandled errors to the operating system,
  215. you can define <CODE>ENABLE_ERROR_RETURN</CODE> instead of using a
  216. TRY...<A HREF="#ONERR">ONERR</A>...<A HREF="#ENDTRY">ENDTRY</A> block.
  217. See the section <A HREF="htretval.html#reterr">Returning Errors</A>
  218. for more information.</P>
  219. <HR>
  220. <H3><A NAME="ER_catch"><U>ER_catch</U></A></H3>
  221. <P><TABLE BORDER="1" CELLPADDING="2"><TR><TD CLASS="CODE"><B><A HREF="keywords.html#short">short</A></B> ER_catch (<B><A HREF="keywords.html#void">void</A></B> *ErrorFrame);</TD></TR></TABLE></P>
  222. <P><B>Catches an error.</B></P>
  223. <P>ER_catch sets up an error handler. It saves the task state in
  224. <I>ErrorFrame</I>, which is usually a buffer
  225. of type <A HREF="#ERROR_FRAME">ERROR_FRAME</A>, and returns 0. The state consists of the values of A2-A7,
  226. D3-D7, and PC. It also records a pointer to the previously saved state, which
  227. makes it a linked list/stack, and yet another two system pointers.
  228. <BR><BR>
  229. If <A HREF="#ER_throwVar">ER_throwVar</A> is called later on (note that some TIOS routines may perform
  230. <A HREF="#ER_throwVar">ER_throwVar</A> in a case of error), it simulates a return from the
  231. previously called ER_catch, and the error code passed into <A HREF="#ER_throwVar">ER_throwVar</A>
  232. will become the result of ER_catch. The processor must be in User mode for this
  233. to work properly.
  234. <BR><BR>
  235. <B>Note:</B> Usually you should not call
  236. this function explicitely. Use the <A HREF="#TRY">TRY</A> macro instead.</P>
  237. <P>See also: <A HREF="#TRY">TRY</A>, <A HREF="#ONERR">ONERR</A>, <A HREF="#ENDTRY">ENDTRY</A>, <A HREF="#FINALLY">FINALLY</A>, <A HREF="#ENDFINAL">ENDFINAL</A>, <A HREF="#ER_throwVar">ER_throwVar</A>, <A HREF="#ER_throw">ER_throw</A>, <A HREF="#ER_success">ER_success</A></P>
  238. <HR>
  239. <H3><A NAME="ER_success"><U>ER_success</U></A></H3>
  240. <P><TABLE BORDER="1" CELLPADDING="2"><TR><TD CLASS="CODE"><B><A HREF="keywords.html#void">void</A></B> ER_success (<B><A HREF="keywords.html#void">void</A></B>);</TD></TR></TABLE></P>
  241. <P><B>Pops the state from the error stack.</B></P>
  242. <P>ER_success pops the state previously saved by <A HREF="#ER_catch">ER_catch</A> off the stack,
  243. i.e. removes the error frame from the linked list. You usually will not call this function
  244. explicitely: the macro <A HREF="#ONERR">ONERR</A> will do this for you.</P>
  245. <HR>
  246. <H3><A NAME="ER_throw"><U>ER_throw</U></A></H3>
  247. <P><TABLE BORDER="1" CELLPADDING="2"><TR><TD CLASS="CODE"><B><A HREF="keywords.html#void">void</A></B> ER_throw (<B><A HREF="keywords.html#short">short</A></B> err_no);</TD></TR></TABLE></P>
  248. <P><B>Throws an error with a constant number.</B></P>
  249. <P>ER_throw works like <A HREF="#ER_throwVar">ER_throwVar</A>, but it
  250. produces much shorter code (only 2 bytes). This is done through the Line 1010
  251. (A-Line) emulator, which emulates an assembly opcode for each error number.
  252. As a consequence, <I>err_no</I> must be constant.</P>
  253. <P>See also: <A HREF="#ER_throwVar">ER_throwVar</A>, <A HREF="#ErrorCodes">ErrorCodes</A></P>
  254. <HR>
  255. <H3><A NAME="ER_throwVar"><U>ER_throwVar</U></A></H3>
  256. <P><TABLE BORDER="1" CELLPADDING="2"><TR><TD CLASS="CODE"><B><A HREF="keywords.html#void">void</A></B> ER_throwVar (<B><A HREF="keywords.html#short">short</A></B> err_no);</TD></TR></TABLE></P>
  257. <P><B>Throws an error.</B></P>
  258. <P>ER_throwVar restores the state previously saved by <A HREF="#ER_catch">ER_catch</A>.
  259. It then returns in such a way that <A HREF="#ER_catch">ER_catch</A> appears to have
  260. returned with the value <I>err_no</I>.
  261. See the TI-Basic manual for a meaning of the various error codes. ER_throwVar
  262. should not be called with a value 0 as <I>err_no</I>. Think of ER_throwVar as a long
  263. jump rather than a subroutine call. Execution does not return from the ER_throwVar call.
  264. <BR><BR>
  265. <B>Note:</B> If you want to use ER_throwVar to bail out to the TIOS from an arbitrary
  266. place, you need to define <CODE>ENABLE_ERROR_RETURN</CODE>.
  267. See the section <A HREF="htretval.html#reterr">Returning Errors</A>
  268. for more information.</P>
  269. <P>See also: <A HREF="#ER_throw">ER_throw</A>, <A HREF="#ErrorCodes">ErrorCodes</A>, <A HREF="#PASS">PASS</A></P>
  270. <HR>
  271. <H3><A NAME="ERD_dialog"><U>ERD_dialog</U></A></H3>
  272. <P><TABLE BORDER="1" CELLPADDING="2"><TR><TD CLASS="CODE"><B><A HREF="keywords.html#short">short</A></B> ERD_dialog (<B><A HREF="keywords.html#short">short</A></B> err_no, <B><A HREF="keywords.html#short">short</A></B> prog_flag);</TD></TR></TABLE></P>
  273. <P><B>Displays an error dialog box.</B></P>
  274. <P>ERD_dialog displays an error dialog box with a message corresponding to the
  275. error code <I>err_no</I>. See the TI manual for a meaning of the various
  276. error codes. ERD_dialog returns <A HREF="alloc.html#Bool">TRUE</A> or
  277. <A HREF="alloc.html#Bool">FALSE</A>, depending of whether the user
  278. exits the dialog box by pressing ENTER or ESC key. This routine may cause
  279. heap compression.
  280. <BR><BR>
  281. <I>prog_flag</I> is a flag which may be <A HREF="alloc.html#Bool">FALSE</A> or
  282. <A HREF="alloc.html#Bool">TRUE</A>. Normally, it needs to be <A HREF="alloc.html#Bool">FALSE</A>,
  283. but when it is <A HREF="alloc.html#Bool">TRUE</A>, in addition to the standard button
  284. whith message "Esc=CANCEL", another button with message "Enter=GOTO" will be
  285. added in the error dialog box. This is mostly useless, but
  286. error dialog boxes have this option (TIOS uses this when you break a BASIC program).
  287. Note, however, that pressing Enter will not perform the actual transfer to the program
  288. editor.</P>
  289. <HR>
  290. <H3><A NAME="ERD_dismissNotice"><U>ERD_dismissNotice</U></A></H3>
  291. <P><A HREF="httigcc.html#minams">AMS 2.00 or higher</A></P>
  292. <P><TABLE BORDER="1" CELLPADDING="2"><TR><TD CLASS="CODE"><B><A HREF="keywords.html#void">void</A></B> ERD_dismissNotice (<B><A HREF="keywords.html#void">void</A></B>);</TD></TR></TABLE></P>
  293. <P><B>Removes the error notice displayed by a prior call to <A HREF="#ERD_notice">ERD_notice</A>.</B></P>
  294. <P>This function causes the screen to be repainted, because it calls
  295. <A HREF="wingraph.html#WinClose">WinClose</A>.<BR>
  296. <B>CAUTION:</B> calling this function without a prior call to
  297. <A HREF="#ERD_notice">ERD_notice</A>, or calling ERD_dismissNotice twice,
  298. can leave the calculator in an unstable state !</P>
  299. <HR>
  300. <H3><A NAME="ERD_notice"><U>ERD_notice</U></A></H3>
  301. <P><A HREF="httigcc.html#minams">AMS 2.00 or higher</A></P>
  302. <P><TABLE BORDER="1" CELLPADDING="2"><TR><TD CLASS="CODE"><B><A HREF="keywords.html#short">short</A></B> ERD_notice (<B><A HREF="keywords.html#short">unsigned</A></B> <B><A HREF="keywords.html#int">char</A></B> <B><A HREF="keywords.html#const">const</A></B> *title, <B><A HREF="keywords.html#short">unsigned</A></B> <B><A HREF="keywords.html#int">char</A></B> <B><A HREF="keywords.html#const">const</A></B> *message);</TD></TR></TABLE></P>
  303. <P><B>Displays an error notice.</B></P>
  304. <P>ERD_notice displays a dialog-looking window with title <I>title</I>, message <I>message</I>
  305. (word-wrapped if necessary), without buttons, that will stay on the screen until
  306. <A HREF="#ERD_dismissNotice">ERD_dismissNotice</A> is called.<BR>
  307. ERD_notice returns TRUE if the window was actually displayed, FALSE otherwise.<BR>
  308. ERD_notice <B>must</B> be paired correctly with <A HREF="#ERD_dismissNotice">ERD_dismissNotice</A>.</P>
  309. <HR>
  310. <H3><A NAME="ERD_process"><U>ERD_process</U></A></H3>
  311. <P><TABLE BORDER="1" CELLPADDING="2"><TR><TD CLASS="CODE"><B><A HREF="keywords.html#void">void</A></B> ERD_process (<B><A HREF="keywords.html#short">short</A></B> err_no);</TD></TR></TABLE></P>
  312. <P><B>Processes an error.</B></P>
  313. <P>ERD_process processes the error with error code <I>err_no</I> by calling
  314. <A HREF="#ERD_dialog">ERD_dialog</A> appropriately. Button "Enter=GOTO" will
  315. be displayed only if the routine concludes from some system flags that the
  316. routine is called from the TI-Basic interpreter (which will not be the case
  317. if you called it from a C or ASM program). Then, ERD_process responds by
  318. starting the appropriate application (for example the text editor if the TI-Basic
  319. interpreter was active and if the user pressed the button "Enter=GOTO").
  320. Principally, there is no difference between ERD_process and
  321. <A HREF="#ERD_dialog">ERD_dialog</A>, except in event-driven applications
  322. (see the <A HREF="events.html">events.h</A> header file).</P>
  323. <HR>
  324. <H3><A NAME="find_error_message"><U>find_error_message</U></A></H3>
  325. <P><A HREF="httigcc.html#minams">AMS 1.01 or higher</A></P>
  326. <P><TABLE BORDER="1" CELLPADDING="2"><TR><TD CLASS="CODE"><B><A HREF="keywords.html#const">const</A></B> <B><A HREF="keywords.html#int">char</A></B> *find_error_message (<B><A HREF="keywords.html#short">short</A></B> err_no);</TD></TR></TABLE></P>
  327. <P><B>Returns a TI-Basic error message string.</B></P>
  328. <P>find_error_message returns a pointer to the text of the TI-Basic error message string
  329. with the code <I>err_no</I>. See the TI-Basic manual for a list of various error codes. If
  330. <I>err_no</I> is not a valid error code, the routine returns a pointer to the string
  331. "Unknown ERROR code", or its localized version if a language localization is active (on
  332. AMS 2.xx).
  333. <BR><BR>
  334. find_error_message may return <A HREF="alloc.html#NULL">NULL</A>.</P>
  335. <HR>
  336. <H3><A NAME="errCode"><U>errCode</U></A></H3>
  337. <P><TABLE BORDER="1" CELLPADDING="2"><TR><TD CLASS="CODE"><B><A HREF="keywords.html#short">unsigned</A></B> <B><A HREF="keywords.html#short">short</A></B> errCode;</TD></TR></TABLE></P>
  338. <P><B>Contains the error number in a TRY...ONERR...ENDTRY block.</B></P>
  339. <P>errCode is an automatic (local) variable which is automatically created in the error handler, and it
  340. contains the error number to allow the program to check what caused the error. This variable
  341. is automatically destroyed after <A HREF="#ENDTRY">ENDTRY</A> statement, i.e. after execution
  342. of the error handler. Variable errCode, because it is local to the <A HREF="#ONERR">ONERR</A>
  343. block, cannot be referenced outside the <A HREF="#ONERR">ONERR</A> block.</P>
  344. <P>See also: <A HREF="#ErrorCodes">ErrorCodes</A></P>
  345. <HR>
  346. <H3><A NAME="ERROR_FRAME"><U>ERROR_FRAME</U></A></H3>
  347. <P><TABLE BORDER="1" CELLPADDING="2"><TR><TD CLASS="CODE"><B><A HREF="keywords.html#typedef">typedef</A></B> <B><A HREF="keywords.html#struct">struct</A></B> ErrorFrameStruct {
  348. <TABLE><TR><TD WIDTH="12"></TD><TD CLASS="CODE">
  349. <B><A HREF="keywords.html#short">unsigned</A></B> <B><A HREF="keywords.html#short">long</A></B> A2, A3, A4, A5, A6, A7;<BR>
  350. <B><A HREF="keywords.html#short">unsigned</A></B> <B><A HREF="keywords.html#short">long</A></B> D3, D4, D5, D6, D7;<BR>
  351. <B><A HREF="keywords.html#short">unsigned</A></B> <B><A HREF="keywords.html#short">long</A></B> NG_control;<BR>
  352. <B><A HREF="keywords.html#int">char</A></B> *RetIndex;<BR>
  353. <B><A HREF="keywords.html#short">unsigned</A></B> <B><A HREF="keywords.html#short">long</A></B> PC;<BR>
  354. <B><A HREF="keywords.html#struct">struct</A></B> ErrorFrameStruct *Link;<BR>
  355. </TD></TR></TABLE>
  356. } ERROR_FRAME [1];</TD></TR></TABLE></P>
  357. <P><B>A type designed for capturing a task state.</B></P>
  358. <P>ERROR_FRAME is a type designed for capturing a task state needed for
  359. catching errors using the <A HREF="#ER_catch">ER_catch</A> command.</P>
  360. <HR>
  361. <H3><A NAME="ErrorCodes"><U>ErrorCodes</U></A></H3>
  362. <P><TABLE BORDER="1" CELLPADDING="2"><TR><TD CLASS="CODE"><B><A HREF="keywords.html#enum">enum</A></B> ErrorCodes {ER_OK = 0, ER_OKAY = 0, ER_EXIT = 1, ER_STOP = 2, ER_OFF = 3, ER_PRGM_STOP = 4, ER_NO_MSG = 9, ER_FUNC_DID_NOT_RETURN_VALUE = 10, ER_TEST_NOT_TRUE_OR_FALSE = 20, ER_ARG_CANNOT_BE_FOLDER = 30, ER_ARGUMENT = 40, ER_ARG_MISMATCH = 50, ER_EXPECTED_BOOL_OR_AGG = 60, ER_ARG_MUST_BE_DECIMAL = 70, ER_ARG_MUST_BE_LABEL = 80, ER_ARGUMENT_MUST_BE_LIST = 90, ER_ARG_MUST_BE_MATRIX = 100, ER_ARG_MUST_BE_PIC = 110, ER_ARG_MUST_BE_PIC_OR_STR = 120, ER_ARG_MUST_BE_STRING = 130, ER_EXPECTED_VAR = 140, ER_ARG_MUST_BE_EMPTY_FOLDER = 150, ER_EXPECTED_ALGEBRAIC = 160, ER_ASAP_TOO_LONG = 161, ER_ATTRIBUTE_NOT_FOUND = 163, ER_BATT_LOW = 165, ER_BOUND = 170, ER_BREAK = 180, ER_CHECKSUM = 185, ER_CIRCULAR_DEFINITION = 190, ER_INVALID_SUCH_THAT = 200, ER_DATATYPE = 210, ER_DEPENDENT_LIMIT = 220, ER_DIFF_EQ_SETUP = 225, ER_DIMENSION = 230, ER_NOT_ENOUGH_ELEMENTS = 230, ER_NON_CONFORMING_LISTS = 240, ER_DIVBY0 = 250, ER_DOMAIN = 260, ER_DUPLICATE_VAR_NAME = 270, ER_ELSEIF_WITHOUT_IF = 280, ER_ELSE_WITHOUT_IF = 280, ER_ENDTRY_WITHOUT_ELSE = 290, ER_EXCESSIVE_ITERATION = 295, ER_EXPECTED_2OR3_ELEMENTS = 300, ER_EXPIRED = 305, ER_APP_EXT_NOT_FOUND = 307, ER_APP_NOT_FOUND = 308, ER_INVALID_NSOLVE_ARG1 = 310, ER_INVALID_SOLVE_ARG1 = 320, ER_FOLDER = 330, ER_FUNCS_IN_DIFF_EQ = 335, ER_INCONSISTENT_UNITS = 345, ER_INVALID_SUBSCRIPT = 350, ER_INVALID_INDIR_STRING = 360, ER_INDIR_STRING_NOT_VARNAME = 360, ER_INDIR_STRING_NOT_FUNNAME = 360, ER_INVALID_ANS = 380, ER_ILLEGAL_ASSIGNMENT = 390, ER_ILLEGAL_ASSIGNMENT_VALUE = 400, ER_INVALID_AXES = 405, ER_ILLEGAL_COMMAND = 410, ER_INVALID_FOLDER_NAME = 420, ER_GRAPH_MODE = 430, ER_INVALID_GUESS = 435, ER_INVALID_IMPLIED_MULT = 440, ER_ILLEGAL_IN_FUNC = 450, ER_ILLEGAL_IN_CUSTOM = 460, ER_ILLEGAL_IN_DIALOG = 470, ER_ILLEGAL_IN_TOOLBAR = 480, ER_CANNOT_EXIT_FROM_TRY = 490, ER_CANNOT_CYCLE_FROM_TRY = 490, ER_CANNOT_GOTO_FROM_TRY = 490, ER_CANNOT_GOTO_INTO_TRY = 490, ER_INVALID_LABEL = 500, ER_INVALID_LIST_OR_MATRIX = 510, ER_INVAL_OUTSIDE_TB_CM = 520, ER_INVAL_OUTSIDE_DG_TB_CM = 530, ER_INVALID_OUTSIDE_DIALOG = 540, ER_MUST_BE_IN_PRGM_OR_FUNC = 550, ER_CYCLE_NOT_IN_LOOP = 560, ER_EXIT_NOT_IN_LOOP = 560, ER_INVALID_PATHNAME = 570, ER_INVALID_POLAR_COMPLEX = 575, ER_ILLEGAL_PRGM_REF = 580, ER_INVALID_SYNTAX_BLOCK = 590, ER_INVALID_TABLE = 600, ER_INVALID_USE_OF_UNITS = 605, ER_INVALID_LOCAL_DECLARATION = 610, ER_EXPECTED_VAR_OR_FUNC = 620, ER_INVALID_VAR_REF = 630, ER_INVALID_VECTOR_SYNTAX = 640, ER_LINK_IO = 650, ER_MAT_NOT_DIAGONALIZABLE = 665, ER_MEMORY = 670, ER_MEMORY_EXHAUSTION = 670, ER_ESTACK_OVERFLOW = 670, ER_STACK_VIO = 673, ER_EXPECTED_LPAR = 680, ER_EXPECTED_RPAR = 690, ER_EXPECTED_DOUBLE_QUOTE = 700, ER_EXPECTED_RIGHT_BRACKET = 710, ER_EXPECTED_RIGHT_BRACE = 720, ER_INVALID_BLOCK_STRUCTURE = 730, ER_MISSING_THEN = 740, ER_NOT_FUNC_OR_PRGM = 750, ER_NO_FUNCS_SEL = 765, ER_NO_SOLUTION = 780, ER_NON_ALGEBRAIC_VARIABLE = 790, ER_UNREAL_RESULT = 800, ER_EXPECTED_REAL = 800, ER_MEMORY_DML = 810, ER_RATIONAL_NUMERIC_OVERFLOW = 830, ER_OVERFLOW = 830, ER_STAT_PLOT = 840, ER_PRGM_NOT_FOUND = 850, ER_RECURSION_TOO_DEEP = 860, ER_RESERVED = 870, ER_SYS_FUNC = 870, ER_ROM_ROUTINE_NOT_AVAILABLE = 875, ER_SEQUENCE_SETUP = 880, ER_SIGNATURE_ERR = 885, ER_SINGULARMAT = 890, ER_SLOPE_FIELD_FUNCS = 895, ER_WEIGHTS_SUM_NOT_POS = 900, ER_LISTS_CONTAIN_NEG = 900, ER_LISTS_NOT2DISCREET = 900, ER_EMPTY_GROUP_NOT_VALID = 900, ER_SYNTAX = 910, ER_UNEXPECTED_CHARACTER = 910, ER_EXPECTED_EQUAL = 910, ER_EXPECTED_FACTOR = 910, ER_TOO_FEW_ARGS = 930, ER_TOO_MANY_ARGS = 940, ER_TOO_MANY_SUBSCRIPTS = 950, ER_TOO_MANY_UNDEFINED = 955, ER_UNDEFINED_VAR = 960, ER_UNLICENSED = 965, ER_GRAPH_FUNC_IN_USE = 970, ER_PROG_OR_FUNC_IN_USE = 970, ER_VAR_IN_USE = 970, ER_LOCKED = 980, ER_PROTECTED = 980, ER_NAME_TOO_LONG = 990, ER_RANGE = 1000, ER_ZOOM = 1010, ER_ILLEGAL_TAG = 1020, ER_UNKNOWN_TAG = 1020, ER_DIVISION_BUG = 1020, ER_MEM_VIO = 1030, ER_FP_TEST_FAIL = 4094, EXPECTED_BOOL_OR_AGG_ERROR = 60, EXPECTED_VAR_ERROR = 140, EXPECTED_ALGEBRAIC_ERROR = 160, INVALID_SUCH_THAT_ERROR = 200, NON_CONFORMING_LISTS_ERROR = 240, EXPECTED_2OR3_ELEMENTS_ERROR = 300, INVALID_NSOLVE_ARG1_ERROR = 310, INVALID_SOLVE_ARG1_ERROR = 320, INVALID_PATHNAME_ERROR = 570, EXPECTED_VAR_OR_FUNC_ERROR = 620, MEMORY_EXHAUSTION_ERROR = 670, ESTACK_OVERFLOW_ERROR = 670, EXPECTED_LPAR_ERROR = 680, EXPECTED_RPAR_ERROR = 690, EXPECTED_DOUBLE_QUOTE_ERROR = 700, EXPECTED_RIGHT_BRACKET_ERROR = 710, EXPECTED_RIGHT_BRACE_ERROR = 720, UNREAL_RESULT_ERROR = 800, EXPECTED_REAL_ERROR = 800, RATIONAL_NUMERIC_OVERFLOW_ERROR = 830, RECURSION_TOO_DEEP_ERROR = 860, SYNTAX_ERROR = 910, UNEXPECTED_CHARACTER_ERROR = 910, EXPECTED_EQUAL_ERROR = 910, EXPECTED_FACTOR_ERROR = 910, TOO_FEW_ARGS_ERROR = 930, TOO_MANY_ARGS_ERROR = 940, TOO_MANY_SUBSCRIPTS_ERROR = 950, TOO_MANY_UNDEFINED_ERROR = 955, GRAPH_FUNC_IN_USE_ERROR = 970, NAME_TOO_LONG_ERROR = 990, ILLEGAL_TAG_ERROR = 1020, UNKNOWN_TAG_ERROR = 1020, DIVISION_BUG_ERROR = 1020};</TD></TR></TABLE></P>
  363. <P><B>An enumeration containing all error codes.</B></P>
  364. <P>This enumeration contains all error codes used by the TIOS. Error names not
  365. starting with <CODE>'ER_'</CODE> are deprecated and introduced only for
  366. compatibility. All of these errors can be
  367. <A HREF="htretval.html#reterr">passed on to the operating system</A>.
  368. You can use your own numbers for errors which you handle in your program, if
  369. you want to use the error-handling system to write more stable programs.</P>
  370. <P>See also: <A HREF="#ER_throw">ER_throw</A>, <A HREF="#ER_throwVar">ER_throwVar</A>, <A HREF="#errCode">errCode</A></P>
  371. <HR>
  372. <H3><A HREF="index.html">Return to the main index</A></H3>
  373. </BODY>
  374. </HTML>