I have an automated script where a window displays, but depending on whether an action was successful or not, one of two windows would display.

For example, my script currently looks like this:

Dim wPass as TWindow, SaveOptsSucc As Boolean, SaveOptsText As String, SavePassText As TLabel, SaveSvcWatchText As TLabel

SaveOptsSucc = False
set wPass = Window("Application='SERVER OPTIONS.EXE' ClassName='#32770' Caption='G-Station Server Options'", tpAttachNoWait)
SaveOptsText = wPass.AttachName
Set SavePassText = Label("Caption='Server Options saved successfully'")
Set SaveSvcWatchText = Label("Caption='There is an instance of Service Watcher running. Please stop Service Watcher before saving server options.'")
'The Label is the text displayed within the displayed window. In this case, the failure window displayed with associated text.

How do I just let the script assign the label caption to a single TLabel object variable and use the InStr function to compare the caption to a specific key word/phrase in order to set the SaveOptsSucc boolean variable? I don't want to assign hundreds of Label Captions to hundreds of TLabel objects.

I appreciate your assistance with this question. Thank you.