MessageBox Rony G. Flatscher How do I display a message box from an ooRexx script ?

I'm wondering if it is possible to display message boxes (similar to those displayed by Basic's MsgBox function) using the OpenOffice.org API.

(Also you could use ".bsf.dialog~messageBox()", ".bsf.dialog~dialogBox()" and/or

"bsf.dialog~inputBox()".)

You can use the following function as a replacement for the Msgbox StarBasic function:

/* Modelled (transcribed from) the Python snippet at {%internal ./Office.MessageBoxWithTheUNOBasedToolkit.snip} for ooRexx ({%external http://www.ooRexx.org}). */ -- needs to be run as a macro: xScriptContext=uno.getScriptContext() -- get the xScriptContext object oDoc=xScriptContext~getDocument -- get the document service (an XModel object) -- oDesktop=xScriptContext~getDesktop -- get the desktop (an XDesktop object) -- oContext=xScriptContext~getComponentContext -- get the context(an XComponentContext object) -- store a directory proxy for the constants in the .local environment .local~vwpa=bsf.wrapStaticFields('{%see com.sun.star.awt.VclWindowPeerAttribute}') /* Defined constants, now retrievable by sending their name as a message to the directory proxy, retrievable via the environment symbol ".vwpa". Here is the list of available button keys: OK, OK_CANCEL, YES_NO, YES_NO_CANCEL, RETRY_CANCEL, DEF_OK, DEF_CANCEL, DEF_YES, DEF_NO, DEF_RETRY */ call testMessageBox oDoc -- now test the message box, supply the document object which has the XModel interface ::requires UNO.CLS -- load UNO support for OpenOffice.org ::routine TestMessageBox use arg doc -- retrieve document component numeric digits 10 -- augment significant numbers in arithmetics from 9 to 10 digits -- get the container window using the XModel interface to start out with parentWin=doc~{%see com.sun.star.frame.XModel%XModel}~getCurrentController~getFrame~getContainerWindow s = "This is a test" -- message text t = "Test" -- title for the message box res = MessageBox(parentWin, s, t, "querybox", .vwpa~YES_NO_CANCEL + .vwpa~DEF_NO) call MessageBox parentWin, "The previous querybox returned:" res, t, "infobox" --# Show a message box with the UNO based toolkit ::routine MessageBox use arg ParentWin, MsgText, MsgTitle, MsgType, MsgButtons if pos(msgType, "messbox infobox errorbox warningbox querybox")=0 then MsgType="messbox" if arg(5, "Omitted") then -- if fifth argument is omitted MsgButtons=.vwpa~ok -- use the "OK" button only -- #describe window properties. aDescriptor=.bsf~new("{%see com.sun.star.awt.WindowDescriptor}") aDescriptor~Type = bsf.getConstant("{%see com.sun.star.awt.WindowClass}", "MODALTOP") aDescriptor~WindowServiceName = MsgType aDescriptor~ParentIndex = -1 aDescriptor~Parent = ParentWin~{%see com.sun.star.awt.XWindowPeer%XWindowPeer} -- #aDescriptor~Bounds = .bsf~new("{%see com.sun.star.awt.Rectangle}") aDescriptor~WindowAttributes = MsgButtons tk = ParentWin~{%see com.sun.star.awt.XWindowPeer%XWindowPeer}~getToolkit msgbox = tk~createWindow(aDescriptor)~{%see com.sun.star.awt.XMessageBox%xMessageBox} msgbox~setMessageText(MsgText) if arg(3,"exists") then -- if third argument (title) exists, use it msgbox~setCaptionText(MsgTitle) return msgbox~execute -- execute the message box and returned pressed key