Sub Main
  Monitor = True
  WWW.Silent = True
  '
  s = ExecuteWWW("http://mail.thetotal.co.nz:7301/PxFBF1/prc1.asp")
  '
  'Page 1 .. prc1.asp
  If Instr(1, s, "Step 1 of 5", 1) > 0 Then 
    Call LogMessage("SUCCESS Step 1: found Login page.")
    XForm("UserID").Value = "john"
    XForm("Password").Value = "john"
    s = ExecuteWWW("SUBMIT")
  Else
    Call LogMessage("ERROR Step 1: Cannot find first Login page.")
    Exit Sub
  End If
  '
  'Page 2 .. prc2.asp
  'Welcome page, follow hyperlink to start a new auction
  If Instr(1, s, "Step 2 of 5", 1) > 0 Then 
    Call LogMessage("SUCCESS Step 2: found welcome page, attempting navigation to page 3.")
    'Scripter needs to look at this page and find that desired hyperlink goes to prc3.asp
    s = ExecuteWWW("http://localhost/pxtest/prc3.asp")
  Else
    Call LogMessage("ERROR Step 2: Did not get expected response of welcome page.")
    Exit Sub
  End If
  '
  'Page 3 .. Fill in form to start a new auction
  If Instr(1, s, "Step 3 of 5", 1) > 0 And Instr(1, s, "ERROR", 1) = 0 Then 
    Call LogMessage("SUCCESS Step 3: now filling in form for a new auction.")
    XForm("item").Value = "Test piece of junk"
    XForm("reserve").Value = "10000.00"
    'Handling radio buttons, if 2 of them, browser gives them indexes "0" and "1"
    'So to click the 2nd option, use (1)
    XForm("xtype")(1).Click
    s = ExecuteWWW("SUBMIT")
  Else
    Call LogMessage("ERROR Step 3: Did not get expected form to fill in.")
    Exit Sub
  End If
  '
  'Page 4, the "are you sure" confirm page, we just move on
  If Instr(1, s, "Step 4 of 5", 1) > 0 Then 
    Call LogMessage("SUCCESS Step 4: auction details accepted, we confirm.")
    s = ExecuteWWW("SUBMIT")
  Else
    Call LogMessage("ERROR Step 4: Did not get expected auction go-ahead.")
    Exit Sub
  End If  
  '
  'Page 5, the "auction goes ahead, here is your lot number" which we need to scrape
  If Instr(1, s, "Step 5 of 5", 1) > 0 Then 
    Call LogMessage("SUCCESS Step 5: auction goes ahead.")
    iPos = Instr(1, s, "Your Lot Number is:", 1)
    'Lot number appears in bold just after this label
    If iPos = 0 Then
      Call LogMessage("ERROR Step 5: Can not find Lot Number")
      Exit Sub
    End If
    'Example of the gentle art of "screen scraping"
    n1 = Instr(iPos, s, "<b>", 1)
    n2 = Instr(iPos, s, "</b>", 1)
    sLotNo = Mid(s, n1+3, n2-n1-3)
    'Code to write sLotNo or otherwise do something useful with it goes here
    'For this test we can just log it.
    Call LogMessage("SUCCESS FINAL: Auction goes ahead, lot number = " & sLotNo)
  Else
    Call LogMessage("ERROR Step 5: Did not get expected auction details.")
  End If  
End Sub