Language StarBasic
| Date: | 04/20/05 |
| Author: | Daniel Hanke |
| URL: | n/a |
| Comments: | 1 |
| Info: | n/a |
| Score: |
sub Main
' Ninety-nine bottles of beer in StarBasic
' for usage in StarOffice/OpenOffice
'
' Daniel Hanke
' http://www2.hs-harz.de/~359/
' June 7, 2002
'
oDesktop = createUnoService("com.sun.star.frame.Desktop")
sUrl = "staroffice.factory:swriter"
oDoc = oDesktop.LoadComponentFromURL(sURL,"_blank",0,mNoArgs)
oText = oDoc.Text
oCursor = oText.createTextCursor()
dim bottles
dim stext
oCursor.CharHeight = 18
p(oText,"99 bottles of beer")
oCursor.CharHeight = 12
for bottles = 99 to 1 step -1
dim sbottle
sbottle = cstr(bottles)+iif(bottles=1," bottle"," bottles")
l(oText,sbottle+" of beer on the wall")
l(oText,sbottle+" of beer ...")
l(oText,"Take one down, pass it around,")
l(oText,iif(bottles=1,"No more bottles",cstr(bottles-1)+_
iif(bottles-1=1," bottle"," bottles"))+" of beer on the wall")
p(oText,"")
next bottles
p(oText,"Time 2 go home")
end sub
sub l(otext as object,stext as string)
otext.insertString(oCursor,stext,FALSE)
otext.insertControlCharacter(oCursor,_
com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,FALSE)
end sub
sub p(otext as object,stext as string)
otext.insertString(oCursor,stext,FALSE)
otext.insertControlCharacter(oCursor,_
com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,FALSE)
end sub
Download Source | Write Comment
Download Source | Write Comment
Add Comment
Please provide a value for the fields Name,
Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.
Please don't post large portions of code here! Use the form to submit new examples or updates instead!
Comments