'---------------------------------------------------------------------- ' ' main() - CGI script back-end main procedure ' ' This is the main() for the VB back end. Note carefully how the error ' handling is set up, and how program cleanup is done. If no command ' line args are present, call Inter_Main() and exit. '---------------------------------------------------------------------- Sub Main() On Error GoTo ErrorHandler If Trim$(Command$) = "" Then ' Interactive start Inter_Main ' Call interactive main End ' Exit the program End If InitializeCGI ' Create the CGI environment '=========== CGI_Main ' Execute the actual "script" '=========== Cleanup: Close #CGI_OutputFN End ' End the program '------------ ErrorHandler: Select Case Err ' Decode our "user defined" errors Case ERR_NO_FIELD: ErrorString = "Unknown form field" Case Else: ErrorString = Error$ ' Must be VB error End Select ErrorString = ErrorString & " (error #" & Err & ")" On Error GoTo 0 ' Prevent recursion ErrorHandler (Err) ' Generate HTTP error result Resume Cleanup '------------ End Sub