hexagon logo

Create folder script

It used to be here.
Parents

  • This was from Chadjac's post-

    Sub Main()
    
    Dim objFSO, objShell
    Dim PCDApp, PCDPartProgram, PCDCommands, PCDCommand, retval
    Dim objFile, objFolder As Object
    
    Set PCDApp=CreateObject("PCDLRN.Application")
    Set PCDPartProgram=PCDApp.ActivePartProgram
    Set PCDCommands=PCDPartProgram.Commands
    
    Set Pathname=PCDPartProgram.GetVariableValue("PATH2")
    
    strPath=Pathname.StringValue
    
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    
    If objFSO.FolderExists(strPath) Then
      'Nothing
    Else
      Set objFile=objFSO.CreateFolder(strPath)
    End If
    
    End Sub
    


    and this is my script
    Sub Main()
    
    Dim objFSO, objShell
    Dim PCDApp, PCDPartProgram, PCDCommands, PCDCommand, retval
    Dim objFile, objFolder As Object
    
    Set PCDApp=CreateObject("PCDLRN.Application")
    Set PCDPartProgram=PCDApp.ActivePartProgram
    Set PCDCommands=PCDPartProgram.Commands
    
    Set Pathname=PCDPartProgram.GetVariableValue("PATH2")
    
    strPath=Pathname.StringValue
    
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    
    If objFSO.FolderExists(strPath) Then
      'Nothing
    Else
      Set objFile=objFSO.CreateFolder(strPath)
    End If
    
    End Sub
    


    If there's a difference, I'm not seeing it...

    This is the code from my PCDMIS program-

                ASSIGN/PATH="Q:\\Quality\\In Process Inspection Plans\\11127-MACHINE\\CMM REPORTS\\"+JN.INPUT+"\ "+PROG_NAME+"_"+V2+".PDF"
                ASSIGN/PATH2="Q:\\Quality\\In Process Inspection Plans\\11127-MACHINE\\CMM REPORTS\\"+JN.INPUT
    PRINT      =LABEL/
                PRINT/REPORT,EXEC MODE=END,$
                  TO_FILE=ON,APPEND=PATH,AUTO OPEN REPORT=OFF,$
                  TO_PRINTER=OFF,COPIES=1,$
                  TO_DMIS_REPORT=OFF,FILE_OPTION=INDEX,FILENAME=,$
                  REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMENSIONS=NO,$
                  TO_EXCEL_OUTPUT=OFF,
                  PREVIOUS_RUNS=DELETE_INSTANCES
    


    It worked perfectly the first few times I ran it. It created the folder from the Job number and put the report in the folder exactly as I was needing- I had to add a refresh script because the report it was saving merely had the report header and nothing else, but the refresh script resolved that. It wasn't until I closed the first program out and opened another program and added the script to the second program that it suddenly refused to work. And then when I went back to the first program and tried to run it again, suddenly I started getting the same error message. And I changed absolutely NOTHING other than the program it was running in.
  • Just an FYI, you only need a double \ when it is ending a string.
    ASSIGN/PATH2="Q:\Quality\In Process Inspection Plans\11127-MACHINE\CMM REPORTS\\"+JN.INPUT
    



    The software doesn't like your single slash in quotes.
    Try changing it to the below code.
    ASSIGN/PATH="Q:\Quality\In Process Inspection Plans\11127-MACHINE\CMM REPORTS\\"+JN.INPUT+"\\"+PROG_NAME+"_"+V2+".PDF"
    
Reply
  • Just an FYI, you only need a double \ when it is ending a string.
    ASSIGN/PATH2="Q:\Quality\In Process Inspection Plans\11127-MACHINE\CMM REPORTS\\"+JN.INPUT
    



    The software doesn't like your single slash in quotes.
    Try changing it to the below code.
    ASSIGN/PATH="Q:\Quality\In Process Inspection Plans\11127-MACHINE\CMM REPORTS\\"+JN.INPUT+"\\"+PROG_NAME+"_"+V2+".PDF"
    
Children
No Data