' test_submit.vbs
' Author: Robert Cowham
' Copyright (c) 2005 Robert Cowham
'
' VBScript file showing how to use P4COM to submit a file.
' Note requirement to use _variant form of several commands.
' Note also the very hacky form of results display via MsgBox (Echo)
'
' P4COM from:
' http://public.perforce.com/guest/robert_cowham/perforce/API/p4com/main/index.html
'
' MIT license applies
'
Option Explicit
Dim p4, arr, str, info, errs, warns
Dim Files
Set p4 = WScript.CreateObject("P4COM.p4")
p4.port = "1666"
p4.client = "bruno_ws"
p4.user = "bruno"
p4.ExceptionLevel = 1
p4.ParseForms ' Important for forms handling like submits
p4.connect
p4.input = "brunopass"
DisplayResult("login")
DisplayResult("info")
DisplayResult("edit //depot/main/jam/jam.c")
' Get the results of change -o and then get/set some of the contents of the change
' form before submitting.
DisplayResult("change -o")
Files = p4.ArrayVar_variant("Files")
PrintArray "Files: ", Files
' At this point we could manipulate the Files array and remove some files we don't want
' to submit and then change the list before submitting using
' p4.ArrayVar_variant("Files") = Files
p4.Var("Description") = "My new description"
DisplayResult("submit -i")
p4.disconnect
sub PrintArray(msg, arr)
if (UBound(arr) >= 0) then
WScript.Echo(msg & join(arr, chr(13) & chr(10)))
end if
end sub
sub DisplayResult(cmd)
WScript.Echo("Cmd: " & cmd)
PrintArray "Info: ", p4.run_variant(cmd)
PrintArray "Warnings: ", p4.Warnings_variant
PrintArray "Errors: ", p4.Errors_variant
end sub