No globals needed for a simple modal dialog.

REM enforce explicit declaration:
Option Explicit
REM search descriptor on module level:
Dim oDesc

Sub Main
Dim oDlg 'do not declare another oDesc on routine level!
Dim iResult as integer

oDesc = getMySearchDescriptor()

REM load "MyLib" in "My Macros"
GlobalScope.BasicLibraries.LoadLibrary("MyLib")
oDlg = CreateUnoDialog(DialogLibraries.MyLib.Dialog1)

oDlg.setVisible(True)
iResult = oDlg.execute()
End Sub

Function getMySearchDescriptor()
Dim d
d = ThisComponent.Sheets.getByIndex(0).createSearchDescriptor()
d.MatchCase = False
'and other stuff like that

REM return the ready made descriptor
getMySearchDescriptor = d
End Function


iResult can return 1 if an OK button has been pushed (property "PushButtonType"). This does not apply to your dialog. The module with it's oDesc variable is kept alive until the modal dialog closes. Instead of function "getMySearchDescriptor" you could also use a sub "setMySearchDescriptor" and set the module variable. In Basic this is a matter of taste.
Sub setMySearchDescriptor()
Dim d
d = ThisComponent.Sheets.getByIndex(0).createSearchDescriptor()
d.MatchCase = False
'and other stuff like that
oDesc = d
End Sub


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org
For additional commands, e-mail: dev-h...@api.openoffice.org

Reply via email to