If/Else/EndIf
Description:
Format:
If <condition>
<true statements> (optional)
Else (optional)
<false statements> (optional)
EndIf
Constructs: |
<condition> |
A phrase or set of phrases that can be evaluated to either TRUE or FALSE. For more information see Comparing Values. |
|
<true statements> |
Any set of Autoweb Statements or Functions to be executed if the Condition is TRUE. This section can be empty. |
|
|
<false statements> |
Any set of Autoweb Statements or Functions to be executed if the Condition is FALSE. This section can be empty. |
Usage:
Example 1:
Go to the My Yahoo! page and check to see if the User is signed –in. The ClickLinkWithText function will return TRUE if the link was present and successfully clicked on.
// Go to My Yahoo!
OpenBrowser (TRUE)
GoToDocument ('my.yahoo.com')
// See if you need to sign-in or not
If ClickLinkWithText ('Sign In')
// You need to sign-in
SetFieldWithLabel ('Yahoo! ID:', 'JohnSmith')
SetFieldWithLabel ('Password:', 'cactus')
ClickButtonWithText ('Sign In')
EndIf
// Leave browser open for User
DisconnectBrowser()
Example 2:
// Create a variable to hold the Search String
String strSearch
// Open the Browser and go to the main Yahoo page
OpenBrowser (TRUE)
GoToDocument ('www.yahoo.com')
If InputBox('Search', 'Enter your search words', 'Words:#40R', 'strSearch', 'Ok') = 'CANCEL'
// The User cancelled, close the Browser
CloseBrowser ()
Else
// Start the Yahoo! Search
SetFieldWithLabel ('Search', strSearch)
ClickButtonWithText ('Search')
DisconnectBrowser ()
EndIf