Jump to content

OpenOffice Basic

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Gune1206 (talk | contribs) at 09:48, 16 May 2014 (Example). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Three modern Basic variants: 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

오픈 오피스의 기본 자체는 다른 언어와 유사하지만, MicrosoftVBA같은, 응용 프로그램 인터페이스 (API) 는 매우 다르다, macro의 예에서 보여주는것과 같이. "paragraph count" 문서를 얻을수 있는 더 쉬운 방법이 있지만, 이 예는 텍스트 문서 안에 있는 각 단락에 순차적으로 접근하기 위한 가장 기본적인 방법을 보여준다.

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

See also

Further reading

  • Steinberg, James. Open Office Basic: An Introduction. CreateSpace Independent Publishing Platform. ISBN 978-1481270939.

BASIC Macros

OpenOffice.org API