FredixBlog


Just my log about anything I could find enjoyable.



Truncate long path names

author Posted by: fredometro on date May 25th, 2007 | filed Filed under: MS-Access

This function is useful when displaying or logging long path names.

Too long path names are annoying in a log file, because they are very often the same. Truncating the path to show only the beginning and the end helps readability.


Public Function TruncatedPath(TheText)
Dim pos1 As Integer
Dim pos2 As Integer
Dim ch As String
Dim i As Integer

pos1 = InStr(3, TheText, "\")
i = Len(TheText)
ch = Mid(TheText, i, 1)
While ch <> "\"
    i = i - 1
    ch = Mid(TheText, i, 1)
Wend
pos2 = Len(TheText) - i + 1

TruncatedPath = Left(TheText, pos1) & "..." & Right(TheText, pos2)
End Function

 

No related posts.

     Add A Comment

You must be logged in to post a comment.


Warning: include(/home/www/web421/html/phpTraffic/write_logs.php) [function.include]: failed to open stream: No such file or directory in /home/websitef/public_html/fredometro.com/wp-content/themes/blueshadow/footer.php on line 15

Warning: include() [function.include]: Failed opening '/home/www/web421/html/phpTraffic/write_logs.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/websitef/public_html/fredometro.com/wp-content/themes/blueshadow/footer.php on line 15