hexagon logo

How to Create an "Object" with Basic Script

I am posting this here to have as a reference. Hope this helps people.

1.
Create a variable for the file system object.

Dim objFSO 'As FileSystemObject
Set objFSO = CreateObject("Scripting.FileSystemObject")


2.
Add a string variable for the directory path where you want to put the file and set it to the desired location or assign a variable from a pull-in from PC-Dmis. I use an operator input, or a hardcoded input.

'using a variable from your program.  The name highlighted in paranthesis and selected by quotations is your 'variable name.  Should always be in all caps.  ("HERE")

Dim opname
Set[SIZE=2][COLOR=#000000] opname = PCDPartProgram.GetVariableValue ("OPERATOR")
[/COLOR]
[/SIZE]'or you may use the following method.  Thus pulling in the program path.

Dim[SIZE=2][COLOR=#000000] PCDApp, PCDPartPrograms, PCDPartProgram, PCDCommands
Set[SIZE=2][COLOR=#000000] PCDApp = CreateObject("PCDLRN.Application")[/COLOR]
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] PCDPartPrograms = PCDApp.PartPrograms[/COLOR]
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] PCDPartProgram = PCDApp.ActivePartProgram[/COLOR]
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] PCDCommands = PCDPartProgram.Commands

PCDpartprogram.Path 
[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2]' or assign the directory from the script.  Thus hardcoding it.

[/SIZE]Dim strDirectory 'As String
strDirectory = "C:\NewDirectory"
'or strDirectory = PCDpartprogram.Path
'or Dim strDirectory
'Set strDirectory = [SIZE=2][COLOR=#000000]PCDPartProgram.GetVariableValue [/COLOR][/SIZE]("FOLDERPATH")



3.
Make sure that the directory folder exists. If the directory is not there, then create it using the file system object or you can use the Program Path to save it in the same directory.

Dim objDirectory 'As Object
If objFSO.FolderExists(strDirectory) Then
Set objDirectory = objFSO.GetFolder(strDirectory)
Else
Set objDirectory = objFSO.CreateFolder(strDirectory)
End If



4.

Make a string variable for the file name and set it to an appropriate value.

Dim strFile 'As String
strFile = "NewFile.txt"


or again use the variable assign method. you can also use a message box and pull in the input from there.

Begin[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dialog[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] DIALOG_1 50,10, 300, 125, oOPERATORINPUT

Dim[SIZE=2][COLOR=#000000] Dialg [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] DIALOG_1[/COLOR]
[/SIZE][/COLOR][/SIZE]TextBox 80,43,50,12, .EditBox_2

Job = Dialg.EditBox_2


5.


Create a variable for the text file and instantiate it. The CreateTextFile method has an optional parameter for overwriting the file it it already exists.

Dim objTextFile 'As Object
Dim blnOverwrite 'As Boolean
blnOverwrite = True
Set objTextFile = objFSO.CreateTextFile(strDirectory & "\" & strFile, blnOverwrite)





6.
Write data to the newly created file with the code below. There are two methods for writing to files, "Write" and "WriteLine." The latter method automatically includes a new line character for you, whereas the former just appends data to what is already present.

objTextFile.Write("This is ")
objTextFile.WriteLine("a new text file")
' This results in the string "This is a new text file"




7.
Close the file with code and properly release all objects.

objTextFile.Close
Set objTextFile = Nothing
Set objDirectory = Nothing
Set objFSO = Nothing
  • Thanks for sharing!


    Sent from my iPhone using Tapatalk
  • Thanks for sharing!


    Sent from my iPhone using Tapatalk


    +1
  • No problems. I ran across most of the snippets on the forum. There was just no consolidated resource for it. So i figured why not make one.
  • Ok I have it working minus the actual writing to file. It gives me an End Sub error. Any ideas as to the simple thing I am sure I am missing.

    '' vpt.se 2010, Rploughe 2014 (modified)
    '
    [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] Main()[/COLOR]
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] objFSO, objShell, strDirectory, InputFolder [/COLOR]
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] PCDApp, PCDPartProgram, PCDCommands, PCDCommand, retval[/COLOR][/SIZE][SIZE=2][COLOR=#007f00][SIZE=2][COLOR=#007f00] 
    
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] PCDApp = CreateObject("PCDLRN.Application")[/COLOR]
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] PCDPartProgram = PCDApp.ActivePartProgram[/COLOR]
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] PCDCommands = PCDPartProgram.Commands[/COLOR]
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] opname = PCDPartProgram.GetVariableValue ("OPERATOR")[/COLOR]
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] joname = PCDPartProgram.GetVariableValue ("JOB")[/COLOR]
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] sampname = PCDPartProgram.GetVariableValue ("SAMP")
    
    [/COLOR]
    Fname = sampname.Stringvalue & " " & opname.Stringvalue & " " 
    strDirectory = PCDPartProgram.Path & "\" & "Job Log"
    strFileName = joname.StringValue
    strPath = strDirectory & "/" & strFileName & ".txt"
    
    [/SIZE][SIZE=2][COLOR=#007f00][SIZE=2][COLOR=#007f00]' Create the File System Object
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] objFolder [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Object
    Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] objFSO = CreateObject("Scripting.FileSystemObject")[/COLOR]
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] objFSO.FolderExists(strDirectory) [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then
    Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] objFolder = objFSO.GetFolder(strDirectory) [/COLOR]
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Else[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] objFolder = objFSO.CreateFolder(strDirectory) [/COLOR]
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If
    
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] objFile [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Object
    Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] blnOverwrite [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Boolean
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]blnOverwrite = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]True
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] objFile = objFSO.CreateTextFile(strPath)
    
    [/COLOR]
    [/SIZE][SIZE=2][COLOR=#007f00][SIZE=2][COLOR=#007f00]'Assignment To look For
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]varname = "WATCHER"
    [/SIZE][SIZE=2][COLOR=#007f00][SIZE=2][COLOR=#007f00]' Is it enabled?
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]sstate = ""
    
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] cnt = 1 [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]To[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] PCDCommands.Count[/COLOR]
    
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] PCDCommand = PCDCommands.Item(cnt)
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ((PCDCommand.[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Type[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = 195) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]And[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (varname = PCDCommand.GetText(DEST_EXPR, 0))) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]wvar = PCDCommand.GetText(SRC_EXPR, 0)
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] wvar = """""" [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 
    sstate = " started @ "
    retval = PCDCommand.PutText("""TRUE""", SRC_EXPR, 0)
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] wvar = """TRUE""" [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]sstate = " ended @ "
    retval = PCDCommand.PutText("""""", SRC_EXPR, 0)
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]
    [B]End [/B][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][B]If <-------[/B]
    [B]Next <--------[/B]
    [/COLOR][/SIZE][/COLOR][/SIZE] 
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] logfile [/COLOR]
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] logFile = objFSO.OpenTextFile(strPath, ForAppending,TristateUseDefault) [/COLOR]
    logFile.[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Write[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Fname & sstate & Date & " " & Time(Now)
    logFile.[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Close
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]
    [/SIZE][SIZE=2][COLOR=#007f00][SIZE=2][COLOR=#007f00]
    'Cleanup
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] PCDPartProgram = [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing
    Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] PCDPartPrograms = [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing
    Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] PCDApp = [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing
    Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] opname=[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing
    Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] joname=[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing
    Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] sampname=[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing
    Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] objFile=[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing
    Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] objFolder=[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing
    Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] objFSO=[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing
    Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] logFile=[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing
    
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Sub
    [/COLOR][/SIZE][/COLOR][/SIZE]
    


    Edit: fixed the End Sub issue. Bolded the part I forgot. Now it gives me an OLE Automation error for the write part. I will fiddle until I get it then post my results.
  • Alright final results. Implementing everything i have posted above. Works like a dream. I will post anything else I get figured out until my boss is smart enough to make me sign a non-disclosure form. Wink.

    '' vpt.se 2010, Rploughe 2014 (modified)
    '
    [SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] Main()[/COLOR]
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] objFSO, objShell, strDirectory, InputFolder [/COLOR]
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] PCDApp, PCDPartProgram, PCDCommands, PCDCommand, retval[/COLOR]
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] objFile, [SIZE=2][COLOR=#000000]objFolder[/COLOR][/SIZE] [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Object
    
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] PCDApp = CreateObject("PCDLRN.Application")[/COLOR]
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] PCDPartProgram = PCDApp.ActivePartProgram[/COLOR]
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] PCDCommands = PCDPartProgram.Commands[/COLOR]
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] opname = PCDPartProgram.GetVariableValue ("OPERATOR")[/COLOR]
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] joname = PCDPartProgram.GetVariableValue ("JOB")[/COLOR]
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] sampname = PCDPartProgram.GetVariableValue ("SAMP")
    
    [/COLOR]
    Fname = sampname.Stringvalue & " " & opname.Stringvalue & " " 
    strDirectory = PCDPartProgram.Path & "\" & "Job Log"
    strFileName = joname.StringValue
    strPath = strDirectory & "/" & strFileName & ".txt"
    
    [/SIZE][SIZE=2][COLOR=#007f00][SIZE=2][COLOR=#007f00]' Create the File System Object
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] objFSO = CreateObject("Scripting.FileSystemObject")
    
    [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] objFSO.FolderExists(strDirectory) [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then
    Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] objFolder = objFSO.GetFolder(strDirectory) [/COLOR]
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Else[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] [/COLOR]
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] objFolder = objFSO.CreateFolder(strDirectory) [/COLOR]
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If
    
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] objFSO.FileExists(strPath) [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] objFile = objFSO.OpenTextFile(strPath)
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Else
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] objFile = objFSO.CreateTextFile(strPath)
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If
    
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#007f00][SIZE=2][COLOR=#007f00]'Assignment To look For
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]varname = "WATCHER"
    [/SIZE][SIZE=2][COLOR=#007f00][SIZE=2][COLOR=#007f00]' Is it enabled?
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]sstate = ""
    
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] cnt = 1 [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]To[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] PCDCommands.Count[/COLOR]
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] PCDCommand = PCDCommands.Item(cnt)
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ((PCDCommand.[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Type[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = 195) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]And[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (varname = PCDCommand.GetText(DEST_EXPR, 0))) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]wvar = PCDCommand.GetText(SRC_EXPR, 0)
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] wvar = """""" [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 
    sstate = " started @ "
    retval = PCDCommand.PutText("""TRUE""", SRC_EXPR, 0)
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] wvar = """TRUE""" [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]sstate = " ended @ "
    retval = PCDCommand.PutText("""""", SRC_EXPR, 0)
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If
    
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Open[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] strPath [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Append[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] #1
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Write[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] #1, Fname & sstate & Date & " " & Time(Now)
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Close[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] #1
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If
    Next
    
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#007f00][SIZE=2][COLOR=#007f00]'Cleanup
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] PCDPartProgram = [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing
    Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] PCDPartPrograms = [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing
    Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] PCDApp = [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing
    Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] opname=[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing
    Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] joname=[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing
    Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] sampname=[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing
    Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] objFile=[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing
    Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] objFolder=[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing
    Set[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] objFSO=[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing
    [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 
    [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Sub
    [/COLOR][/SIZE][/COLOR][/SIZE]
    
  • Sweet!

    Thanks for respecting the credit in your modified version.
  • Hey no problem, credit goes where it is deserved. I have even begun placing http://www.pcdmisforum.com in them to know where I referenced them from. lol