Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I'm trying a make an ilogic rule that converts our vault file structure to our company's file structure.
The issue I'm having is the function creates the correct string value, but when I try to return it shows up blank.
Rule below. Highlighted the areas giving me trouble.
Sub Main Dim filepath As String = ThisDoc.Path filepath = "C:\_Vault\Designs\Customers\Koppers\Galesburg, IL\22-7008M Sorter Upgrade Equipment\29-Upper Drag Chain\01-Catwalk\22-321127.ipt" filepath = filepath.Replace("C:\_IPI_Vault\Designs", "T:") Dim index As Integer ' Dim folderpath As String ' If filepath.Contains("A Level 2 customers") ' index = GetNthIndex(filepath & "\", "\", 6) ' folderpath = CreateFolderPath(filepath.Split("\"), Left(filepath, index), 6) ' Else ' index = GetNthIndex(filepath & "\", "\",5) ' folderpath1 = CreateFolderPath(filepath.Split("\"), Left(filepath, index), 5) ' MessageBox.Show(folderpath1) ' End If index = GetNthIndex(filepath & "\", "\", 5) Dim folderpath As String folderpath = CreateFolderPath(filepath.Split("\"), Left(filepath, index), 5) MessageBox.Show(folderpath) End Sub Public Function GetNthIndex(searchString As String , charToFind As Char, n As Integer) As Integer Dim charIndexPair = searchString.Select(Function(c, i) New With {.Character = c, .Index = i }) _ .Where(Function(x) x.Character = charToFind).ElementAtOrDefault(n - 1) Return If (charIndexPair IsNot Nothing, charIndexPair.Index, -1) End Function Public Function CreateFolderPath(folders As String(), folderpath As String, i As Integer) ' MessageBox.Show(folderpath) ' MessageBox.Show(folderpath) If IO.Directory.Exists(folderpath & "\Sub Jobs\" & folders(i)) CreateFolderPath(folders, folderpath & "\Sub Jobs\" & folders(i), i + 1) Else MessageBox.Show(folderpath) Return folderpath End If End Function
Solved! Go to Solution.