Content deleted Content added
Sfan00 IMG (talk | contribs) |
MaxBech1975 (talk | contribs) Reverted to revision 623945701 by Rautamiekka (talk). (TW) |
||
Line 1:
{{inline citations|date=December 2013}}
[[File:TriBasicExample.png|thumb|Three modern Basic variants: [[Mono (software)|Mono]] Basic, OpenOffice Basic and [[Gambas]].]]
'''OpenOffice Basic''' (formerly known as StarOffice Basic or '''StarBasic''' or '''OOoBasic''') is a dialect of the [[programming language]] [[BASIC]] that originated with the [[StarOffice]] [[office suite]] and spread through [[OpenOffice.org]] and derivatives such as [[LibreOffice]] (where it is known as '''LibreOffice Basic''').
== Example ==
Although OpenOffice Basic itself is similar to other dialects of BASIC, such as [[Microsoft]]'s [[Visual Basic for Applications|VBA]], the [[application programming interface]] (API) is very different, as the example below of a [[Macro (computer science)|macro]] illustrates. While there is a much easier way to obtain the "paragraph count" document property, the example shows the fundamental methods for accessing each paragraph in a text document, sequentially.
<!--oobas = openoffice basic; see [[mw:Extension:SyntaxHighlight_GeSHi#Supported_languages]] -->
<syntaxhighlight lang="oobas">
Sub ParaCount
'
' Count number of paragraphs in a text document
'
Dim Doc As Object, Enum As Object, TextEl As Object, Count As Long
Doc = ThisComponent
' Is this a text document?
If Not Doc.SupportsService("com.sun.star.text.TextDocument") Then
MsgBox "This macro must be run from a text document", 64, "Error"
Exit Sub
End If
Count = 0
' Examine each component - paragraph or table?
Enum = Doc.Text.CreateEnumeration
While Enum.HasMoreElements
TextEl = Enum.NextElement
' Is the component a paragraph?
If TextEl.SupportsService("com.sun.star.text.Paragraph") Then
Count = Count + 1
End If
Wend
'Display result
MsgBox Count, 0, "Paragraph Count"
End Sub
</syntaxhighlight>
== See also ==
*[[Comparison of office suites]]
== Further reading ==
*{{Cite book|first=James|last=Steinberg|title=Open Office Basic: An Introduction|ISBN=978-1481270939|publisher=CreateSpace Independent Publishing Platform}}
== External links ==
=== BASIC Macros ===
*[http://wiki.services.openoffice.org/wiki/Documentation/BASIC_Guide OpenOffice.org BASIC Programming Guide] wiki
*[http://wiki.services.openoffice.org/wiki/VBA OpenOffice.org VBA emulation model project] (still in heavy development)
*[http://www.pitonyak.org/oo.php Andrew Pitonyak's macro information]
=== OpenOffice.org API ===
*[http://api.openoffice.org/ OpenOffice.org/StarOffice API Project Page]
**[http://api.openoffice.org/SDK/index.html OpenOffice.org SDK]
|