hexagon logo

variables create file folder?

Hey Guys,

How would go about creating file folders from variables?

each time I have a new Work order number, I have to go create the file folder on my Network drive and change the location in the print command to dump the results into that folder.

my question is since I'm entering the information in the startup to crop the information into my header, can i automate it to create the folder and everything for me, so i don't have to manually create and change everything?

example:
ASSIGN/WO=C1.input ( lets say WO = 12345 )

create the folder C:\reports\12345
and then have the print command automatically dump to that folder without manually changing the destination?
i know it only takes a minute to create and change this stuff but after you do it enough times during the day it make me wonder if i could just program it to make those changes.

Thoughts on how i would go about doing this?

Parents
  • If you have the home page turned on and access to the internet, you can download an example routine and script from the "Example Routines" section of the "Discover" tab. This is the code for the script that creates new folders...

    '
    ' Creates the file path (folder location) passed In via ARG1 As PATH - ( PATH String must be enclosed In " " & End With \\ )
    ' iterates through String looking For \ And checks If Each folder exists
    ' If the folder does Not exist, it creates it before checking the Next level down Until it Gets To the End of the full path
    '
    ' To use this script, insert a basic script command In your PC-Dmis Measurement Routine, navigate To it's location On your PC, Then enter your required path As ARG1
    ' example of finished command when viewed In the PC-Dmis edit window (command mode)...
    '
    '                                       location of this script On local PC
    '                                                         |
    '
    '   CS1        =SCRIPT/FILENAME= C:\USERS\Public\DOCUMENTS\SCRIPTS\MAKE_FOLDER.BAS
    '                    Function/Main,SHOW=YES,ARG1="C:\\USERS\\PUBLIC\\DOCUMENTS\\NewFolder1\\NewFolder2\\NeFolder3\\",,
    '                    STARTSCRIPT/                                                                            
    '                    ENDSCRIPT/                                                 |
    '                                  Full path of new folder (Or folders) that you want To create, enclosed In " " & ending With \\
    '
    '
    Sub Main(PATH As String)
        Dim objFSO, objShell
        Dim objFile, objFolder As Object
        Dim SubPath As String
        Dim a,b  As Integer
        
        Set objFSO = CreateObject("Scripting.FileSystemObject")
        
        a=1
        b=1
        Do
            SubPath = Left(PATH,Instr(a,PATH,"\"))
            b=Instr(a,PATH,"\")
            a=b
            a=a+1
            If objFSO.FolderExists(SubPATH) Then
              'Nothing
                Else
                  Set objFile=objFSO.CreateFolder(SubPath)
            End If
            If SubPath = PATH Then
              Exit Do
            End If
        Loop
    End Sub
    ​
Reply
  • If you have the home page turned on and access to the internet, you can download an example routine and script from the "Example Routines" section of the "Discover" tab. This is the code for the script that creates new folders...

    '
    ' Creates the file path (folder location) passed In via ARG1 As PATH - ( PATH String must be enclosed In " " & End With \\ )
    ' iterates through String looking For \ And checks If Each folder exists
    ' If the folder does Not exist, it creates it before checking the Next level down Until it Gets To the End of the full path
    '
    ' To use this script, insert a basic script command In your PC-Dmis Measurement Routine, navigate To it's location On your PC, Then enter your required path As ARG1
    ' example of finished command when viewed In the PC-Dmis edit window (command mode)...
    '
    '                                       location of this script On local PC
    '                                                         |
    '
    '   CS1        =SCRIPT/FILENAME= C:\USERS\Public\DOCUMENTS\SCRIPTS\MAKE_FOLDER.BAS
    '                    Function/Main,SHOW=YES,ARG1="C:\\USERS\\PUBLIC\\DOCUMENTS\\NewFolder1\\NewFolder2\\NeFolder3\\",,
    '                    STARTSCRIPT/                                                                            
    '                    ENDSCRIPT/                                                 |
    '                                  Full path of new folder (Or folders) that you want To create, enclosed In " " & ending With \\
    '
    '
    Sub Main(PATH As String)
        Dim objFSO, objShell
        Dim objFile, objFolder As Object
        Dim SubPath As String
        Dim a,b  As Integer
        
        Set objFSO = CreateObject("Scripting.FileSystemObject")
        
        a=1
        b=1
        Do
            SubPath = Left(PATH,Instr(a,PATH,"\"))
            b=Instr(a,PATH,"\")
            a=b
            a=a+1
            If objFSO.FolderExists(SubPATH) Then
              'Nothing
                Else
                  Set objFile=objFSO.CreateFolder(SubPath)
            End If
            If SubPath = PATH Then
              Exit Do
            End If
        Loop
    End Sub
    ​
Children
No Data