User Tools

Site Tools


guide_20to_20writing_20libraries

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

guide_20to_20writing_20libraries [2018/03/31 13:19]
127.0.0.1 external edit
guide_20to_20writing_20libraries [2018/04/15 18:19] (current)
tbest3112 Added syntax highlighting
Line 25: Line 25:
 \\  \\ 
  
-  * Temporary variables (other than formal parameters) used within an individual procedure or function should **always** be declared as LOCAL or PRIVATE. Note that PRIVATE variables are incompatible with certain types of error trapping, in which the main program attempts to recover from an error. This is because if an error occurs at a time when a variable has been made PRIVATE you cannot call that routine again (it will be treated as a re-entrant call). This problem can be circumvented by careful use of local error trapping as follows:+  * Temporary variables (other than formal parameters) used within an individual procedure or function should **always** be declared as LOCAL or PRIVATE. Note that PRIVATE variables are incompatible with certain types of error trapping, in which the main program attempts to recover from an error. This is because if an error occurs at a time when a variable has been made PRIVATE you cannot call that routine again (it will be treated as a re-entrant call). This problem can be circumvented by careful use of local error trapping as follows: ​ 
 +<code bb4w>
         DEF PROCtest         DEF PROCtest
         PRIVATE list,​of,​privates         PRIVATE list,​of,​privates
Line 31: Line 32:
         REM Rest of procedure here         REM Rest of procedure here
         ENDPROC         ENDPROC
-\\ +</​code>​\\ 
  
   * Avoid doing anything within the library which could disrupt operation of the main program. For example don't disable interrupts for any longer than necessary (e.g. **WAIT 0** is probably acceptable but **WAIT 1** isn't) and don't change any global settings (e.g. the ***FLOAT** mode) - even if you restore them before returning from the library the operation of an interrupt routine could be affected.   * Avoid doing anything within the library which could disrupt operation of the main program. For example don't disable interrupts for any longer than necessary (e.g. **WAIT 0** is probably acceptable but **WAIT 1** isn't) and don't change any global settings (e.g. the ***FLOAT** mode) - even if you restore them before returning from the library the operation of an interrupt routine could be affected.
guide_20to_20writing_20libraries.txt · Last modified: 2018/04/15 18:19 by tbest3112