Openoffice Base Macro Error Handling
Contents |
OpenOffice.org Basic Overview of a Basic Program Working With Variables Strings Numbers Boolean Values Date and Time Arrays Scope and Life Span of Variables Constants Operators Branching Loops Procedures and Functions Error Handling Other Instructions Runtime Library Conversion Functions Strings Date and Time Files and
"on Error Goto -1"
Directories Message and Input Boxes Other Functions Introduction to the API Universal Network Objects on error goto -1 vba excel (UNO) Properties and Methods Modules, Services and Interfaces Tools for Working with UNO Overview of Central Interfaces Working with Documents The StarDesktop openoffice iserror Styles and Templates Text Documents The Structure of Text Documents Editing Text Documents More than Just Text Spreadsheet Documents The Structure of Spreadsheets Rows and Columns Cells and Ranges Formatting Spreadsheet Documents Editing Spreadsheet Documents Drawings and Presentations The Structure of Drawings Editing Drawing Objects Presentations Charts (Diagrams) Using Charts in Spreadsheets The Structure of Charts Chart Types Databases SQL: a Query Language Types of Database Access Data Sources Database Access Dialogs Working With Dialogs Properties Events Dialog Control Elements Forms Working With Forms Control Element Forms Database Forms < Previous Page Next Page > Correct handling of error situations is one of the most time-consuming tasks of programming. OpenOffice.org Basic provides a range of tools for simplifying error handling. The On Error Instruction The On Error instruction is the key to any error handling: Sub Test On Error Goto ErrorHandler ' ... undertake task during which an error may occur Exit Sub ErrorHandler: ' ... individual code for error handling End Sub The On Error Goto ErrorHandler line defines how OpenOffice.org Basic proceeds in the event of an error. The Goto ErrorHandler ensures that OpenOffice.org Basic exits the current program line and then executes the ErrorHandler: code. The Resume Command The Resume Next command continues the program from the line that follows where the error occurred in the program after the code in the error handler has been executed: ErrorHandler: ' ... individual code for error handling Resume Next Use the Resume Proceed command to specify a jump point for continuing the program after error handling: ErrorHandler: ' ... individual code for error handling Resume Proceed Proceed: ' ... the program continues here after the error The term Proceed is a label. It could be for example, A247. The syntax for label names is the same as for variable names. To continue a program without an error message when an error occurs, use the following format: Sub Test On Error Resume Next ' ... perform task during wh
an error occurs, or resumes program execution. Syntax: On {[Local] Error GoTo Labelname | GoTo 0 | Resume Next} Parameters: GoTo Labelname: If an error occurs, enables the error-handling routine that starts at the line "Labelname". Resume Next: If an error occurs, program execution continues with the statement that follows the statement in which the error occurred. GoTo 0: Disables the error handler in the current procedure. Local: "On error" is global in scope, and remains active until canceled by another "On error" https://wiki.openoffice.org/wiki/Documentation/BASIC_Guide/Error_Handling statement. "On Local error" is local to the routine which invokes it. Local error handling overrides any previous global setting. When the invoking routine exits, the local error handling is canceled automatically, and any previous global setting is restored. The On Error GoTo statement is used to react to errors that occur in a macro. Example: Sub ExampleReset On Error GoTo ErrorHandler Dim iNumber As Integer Dim https://help.libreoffice.org/Basic/On_Error_GoTo_..._Resume_Statement_Runtime iCount As Integer Dim sLine As String Dim aFile As String aFile = "c:\data.txt" iNumber = Freefile Open aFile For Output As #iNumber Print #iNumber, "This is a line of text" Close #iNumber iNumber = Freefile Open aFile For Input As iNumber For iCount = 1 To 5 Line Input #iNumber, sLine If sLine <>"" Then Rem End If Next iCount Close #iNumber Exit Sub ErrorHandler: Reset MsgBox "All files will be closed",0,"Error" End Sub Retrieved from "http://help.libreoffice.org/index.php?title=Basic/On_Error_GoTo_..._Resume_Statement_Runtime&oldid=430250" Category: ENEN Navigation menu Personal tools Log in Namespaces Page Discussion Variants Views Read View source View history More Search Navigation Download LibreOffice Main page Random page Tools What links here Related changes Special pages Printable version Permanent link Page information This page was last modified 18:14:50, 2013-04-08 by LibreOffice Help user WikiSysop. Content is available under the GNU Lesser General Public License (LGPLv3), unless otherwise specified, originally based on OpenOffice.org help. "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy unless otherwise noted. Pr
Music Digital Photography & Video Games & Strategy Guides Project Management Mobile & Wireless Computing Education & Reference Encyclopedias Test Preparation Studying & Workbooks Schools & Teaching Writing, Research & Publishing http://flylib.com/books/en/4.290.1.24/1/ Guides Foreign Language Study & Reference Atlases & Maps Dictionaries & Thesauruses Words, Language & Grammar College & University Trivia & Fun Facts Consumer Guides Business & Investing Industries & Professions Management & Leadership Organizational Behavior Personal Finance Small Business & Entrepreneurship Popular Economics Marketing & Sales Finance Skills Business Life Economics Job Hunting & Careers Biography & error goto History Reference International Real Estate Investing Women & Business Science & Math Mathematics Technology Reference Earth Sciences Physics Biological Sciences Behavioral Sciences Nature & Ecology Astronomy & Space Science History & Philosophy Experiments, Instruments & Measurement Agricultural Sciences Category list Computers & Technology Programming Languages & Tools Assembly Language Programming Software Education & Reference Encyclopedias Test Preparation Studying & on error goto Workbooks Schools & Teaching Similar pages Section 19.7. ErrorsError HandlingTrapping Errors with evalMacro RepetitionsChapter 23: JavaScript Programming Practices404 Not FoundYnot Logic Simulator: A Literate C Program8.8. Dealing with Deviations and ErrorsOperation of OSPF14.2 Preventing Duplicates from Occurring in a TableFixing Compile-Time BugsTroubleshooting ChecklistFirst, the ResearchTroubleshooting Remote Desktop Error Handling using On Error Buy on amazon.com >> Pitonyak A. << Previous page Table of contents Next page >> Error Handling using On Error Errors are usually placed into three "categories"-compile time, run time, and logic. Compile-time errors are typically syntax errors such as missing double quotation marks that prevent your macro from compiling. Compile-time errors are the easiest to deal with because they are found immediately and the IDE shows you which line caused the problem. Run-time errors compile properly but cause an error when the macro runs. For example, dividing by a variable that at some point evaluates to zero will cause a run-time error. The third type, logic errors, are mistakes in the business logic of the program: They compile and run okay,
be down. Please try the request again. Your cache administrator is webmaster. Generated Sun, 23 Oct 2016 16:37:24 GMT by s_wx1126 (squid/3.5.20)