Advanced Examples / Code snippets

Advanced Examples / Code snippets

Top  Previous  Next

1. Check all bookmarks and display a message box with the number of changed bookmarks


CheckBookmarks /all
$Updated = GetUpdatedBookmarkCount
MessageBox "Bookmarks changed: {$Updated}" /beep



2. Check all bookmarks. If updates are available, then create a report with a dynamic/unique filename and send it by e-mail


CheckBookmarks /all
if GetUpdatedBookmarkCount=then goto NoUpdates
  $filename = GetUniqueID + ".htm"
  CreateReport /template="{programdir}examples\report_template_changes.htm" /output="c:\{$filename}" /bookmarks=changed
  SendMail /recipient="," /subject="WSW-Report" /body="Attached a WSW report" /attachfile="c:\{$filename}"
Label NoUpdates



3. Display a QuestionBox and perform different actions dependent from the button that has been 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


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 opened


// 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"