Advanced Examples / Code snippets
1. Check all bookmarks and display a MessageBox with the number of changed bookmarks
CheckBookmarks /all
$Updated = GetUpdatedBookmarkCount
MessageBox "Bookmarks changed: {$Updated}" /beep
2. Check all bookmarks. If updates are available, create a report with a dynamic, unique filename and send it by email
CheckBookmarks /all
if GetUpdatedBookmarkCount=0 then goto NoUpdates
$filename = GetUniqueID + ".htm"
CreateReport /template="{programdir}examples\report_template_changes.htm" /output="c:\{$filename}" /bookmarks=changed
SendMail /recipient="support@domain.com,info@domain2.com" /subject="WSW-Report" /body="Attached a WSW report" /attachfile="c:\{$filename}"
Label NoUpdates
3. Display a QuestionBox and perform different actions, depending on the button that was clicked
QuestionBox "Click yes or no"
if GetQuestionBoxResult="yes" then goto yes_has_been_clicked
if GetQuestionBoxResult="no" then goto no_has_been_clicked
label yes_has_been_clicked
// insert commands here
goto continue
label no_has_been_clicked
// insert commands here
label continue
4. Loop with 10 iterations
$i=1
Label BeginLoop1
if $i > 10 then goto EndLoop1
// commands, for example a Messagebox which displays the iteration number
MessageBox "Iteration #: {$i}"
$i = $i + 1
goto BeginLoop1
Label EndLoop1
5. Open a bookmark file if it is not currently open
// Open the bookmark file "c:\wsw\bm.wsw" if it is not the opened bookmark file
$s1 = "{bookmarkdir}" + GetBookmarkFilename
$s1 = Lowercase($s1)
if $s1 <> "c:\wsw\bm.wsw" then OpenBookmarkFile "c:\wsw\bm.wsw"
6. Check bookmarks at the beginning of every full hour
Label myStart
$sHH = GetDateTime("hh")
$nHH = StrToInt($sHH)
$nHH = $nHH + 1
if $nHH > 23 then $nHH = 0
WaitUntilTime "{$nHH}:00"
CheckBookmarks /all
goto myStart