VERSION 5.00 Begin VB.Form SubmitForm Caption = "Submit" ClientHeight = 6150 ClientLeft = 60 ClientTop = 450 ClientWidth = 9390 LinkTopic = "Form1" ScaleHeight = 6150 ScaleWidth = 9390 StartUpPosition = 3 'Windows Default Begin VB.TextBox Description Height = 1575 Left = 1320 TabIndex = 4 Text = "Description" Top = 240 Width = 7335 End Begin VB.CommandButton cmdClose Cancel = -1 'True Caption = "Cancel" Height = 495 Left = 4320 TabIndex = 3 Top = 4920 Width = 1455 End Begin VB.CommandButton cmdSubmit Caption = "&Submit" Default = -1 'True Height = 495 Left = 2640 TabIndex = 2 Top = 4920 Width = 1455 End Begin VB.ListBox Files Height = 2085 ItemData = "SubmitForm.frx":0000 Left = 1320 List = "SubmitForm.frx":0007 Style = 1 'Checkbox TabIndex = 0 Top = 2040 Width = 7335 End Begin VB.Label Label1 Alignment = 1 'Right Justify Caption = "Description:" Height = 375 Index = 1 Left = 120 TabIndex = 5 Top = 240 Width = 975 End Begin VB.Label Label1 Alignment = 1 'Right Justify Caption = "Files:" Height = 375 Index = 0 Left = 120 TabIndex = 1 Top = 2040 Width = 975 End End Attribute VB_Name = "SubmitForm" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit '******************************************************************************* ' ' Copyright (c) 2003, Robert Cowham and Vaccaperna Systems Ltd. All rights reserved. ' ' Redistribution and use in source and binary forms, with or without ' modification, are permitted provided that the following conditions are met: ' ' 1. Redistributions of source code must retain the above copyright ' notice, this list of conditions and the following disclaimer. ' ' 2. Redistributions in binary form must reproduce the above copyright ' notice, this list of conditions and the following disclaimer in the ' documentation and/or other materials provided with the distribution. ' ' THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ' IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ' ARE DISCLAIMED. IN NO EVENT SHALL VACCAPERNA SYSTEMS LTD. BE LIABLE FOR ANY ' DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ' (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; ' LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ' ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ' (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ' SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ' ' ******************************************************************************* ' ' Name: SubmitForm.frm ' ' Author: Robert Cowham ' ' Description: ' Show how to execute a command such as "change -o" and then "submit -i" ' and allow the user to manipulate things in between. ' ' Note there job lists available etc (ignored in this demo). ' ' No error handling! ' ****************************************************************************** Dim m_p4 As P4COM.p4 Dim m_Files() As String Dim m_vaFiles() As Variant ' For testing with Variant arrays Dim OutputArr() As String Dim ErrorArr() As String Public Sub DoSubmit(p As P4COM.p4) Dim i As Integer ' Demonstrates how to handle commands which take -o and -i flags, ' in this case "change -o" and "submit -i" to commit the results. ' Copy environment since we want to set ParseForms on for this connection Set m_p4 = p m_p4.Connect m_p4.SetProg "P4OFCTest" m_p4.SetVersion "Ver1.0" OutputArr = m_p4.run("change -o") Description.Text = m_p4.Var("Description") ' Simple string variable m_Files = m_p4.ArrayVar("Files") ' StringArray variable Files.Clear For i = LBound(m_Files) To UBound(m_Files) Files.AddItem m_Files(i) Next Me.Show vbModal Unload Me End Sub Private Sub cmdClose_Click() Unload Me End Sub Private Sub cmdSubmit_Click() On Error GoTo Error_Block Dim i As Integer Dim j As Integer m_p4.Var("Description") = Description.Text ' Setting string var j = 0 For i = 0 To Files.ListCount - 1 If Files.Selected(i) Then ReDim Preserve m_Files(j) ReDim Preserve m_vaFiles(j) m_Files(j) = Files.List(i) m_vaFiles(j) = Files.List(i) j = j + 1 End If Next If j = 0 Then MsgBox "No files selected!" Else m_p4.ArrayVar("Files") = m_Files ' Note the following is equivalent - it just uses a Variant array instead of String array ' m_p4.ArrayVarVar("Files") = m_vaFiles OutputArr = m_p4.run("submit -i") ErrorArr = m_p4.Errors Dim s As String s = Join(OutputArr, " ") s = s & vbCrLf & "Errors: " & Join(ErrorArr, " ") MsgBox s End If Exit_Block: Unload Me Exit Sub Error_Block: MsgBox "Error occurred in submit: " & Err.Description, vbExclamation Resume Exit_Block End Sub