home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1999 January / dppcpro0199a.iso / January / Fp98 / SDK / Utility / Fplaunch / fplaunch.bas < prev    next >
Encoding:
BASIC Source File  |  1997-09-18  |  2.3 KB  |  91 lines

  1. Attribute VB_Name = "FPLaunch"
  2. Option Explicit
  3.  
  4. Sub Main()
  5.  
  6.     Dim filename As String
  7.     Dim server As String
  8.     Dim web As String
  9.     Dim user As String
  10.     Dim page As String
  11.     Dim fno As Integer
  12.     Dim FPExplorer As Object
  13.     Dim ret As Long
  14.     Dim webURL As String
  15.     Dim newWebURL As String
  16.     
  17.     Const ErrPrompt = "Error in FrontPage Launcher"
  18.     Const FPExplorerID = "FrontPage.Explorer"
  19.     Const prefix = "http://"
  20.  
  21.     filename = Trim$(Command$)
  22.     If filename = "" Or InStr(LCase(filename), ".fpl") = 0 Then
  23.         MsgBox "The 'fplaunch' helper app expects a path to a .fpl file on the command line.", vbCritical, ErrPrompt
  24.         End
  25.     End If
  26.  
  27.     fno = FreeFile
  28.     On Error GoTo nofile
  29.     Open filename For Input As #fno
  30.     
  31.     On Error GoTo badfile
  32.     Line Input #fno, server
  33.     server = Trim$(server)
  34.     Line Input #fno, web
  35.     web = Trim$(web)
  36.     Line Input #fno, user
  37.     user = Trim$(user)
  38.     Line Input #fno, page
  39.     page = Trim$(page)
  40.     Close #fno
  41.  
  42.     If (server = "" Or web = "" Or page = "") Then
  43.         MsgBox "Bad variable in parameter file.", vbCritical, ErrPrompt
  44.         End
  45.     End If
  46.  
  47.     On Error GoTo badole
  48.  
  49.     Set FPExplorer = CreateObject(FPExplorerID)
  50.     
  51.     webURL = FPExplorer.vtiGetWebURL
  52.     newWebURL = server & "/" & web
  53.     If Left$(newWebURL, Len(prefix)) <> prefix Then
  54.         newWebURL = "http://" & newWebURL
  55.     End If
  56.     If webURL <> newWebURL Then
  57.         If Not FPExplorer.vtiOpenWeb(server, web, user) Then
  58.             If Len(user) > 0 Then
  59.                 MsgBox "Couldn't open web '" & newWebURL & "' as user '" & user & "'.", vbCritical, ErrPrompt
  60.             Else
  61.                 MsgBox "Couldn't open web '" & newWebURL & "'.", vbCritical, ErrPrompt
  62.             End If
  63.             GoTo badweb
  64.         End If
  65.     End If
  66.     
  67.     ret = FPExplorer.vtiEditWebPage(page)
  68.     If ret <> 1 Then
  69.         MsgBox "Couldn't edit page '" & server & "/" & web & "/" & page & "'."
  70.     End If
  71.  
  72. badweb:
  73.     Set FPExplorer = Nothing
  74.  
  75.     End
  76.  
  77. badole:
  78.     Exit Sub
  79.  
  80. badfile:
  81.     MsgBox "Bad format in parameter file.", vbCritical, ErrPrompt
  82.     Close #fno
  83.     Exit Sub
  84.  
  85. nofile:
  86.     MsgBox "Unable to open parameter file.", vbCritical, ErrPrompt
  87.     Exit Sub
  88.  
  89. End Sub
  90.  
  91.