|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
File problem
Hi
I have this function that works fine on my local directory strDirectory = "c:\input" it gives me results e117.txt, e525, p42 etc but when I map it to strDirectory = "\\the-mapps-ht04\mysdata\ghai56\internal holding\Input Files2" it gives "\\the-mapps-ht04\mysdata\ghai56\internal holding\Input Files2" instead of just e117 this the function Code:
Y = Len(filename)- Len(strDirectory)+1
For i =y To Len(filename)
x = Mid(filename, i, i + 1)
'wscript.echo "Current x: " & x
If Asc(x) >= 65 Then
position = i
Exit For
End If
Next
findquestion = Right(filename, Len(filename) - (position) + 1)
end function
Thanks in advance |
|
#2
|
|||
|
|||
|
Where do you get the length of the filename and directory from? Look there for your problem.
__________________
====== Doug G ====== I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain |
|
#3
|
|||
|
|||
|
filename is the entire path and strdirectory contains part of the path excluding the acutal filename. I have a bunch of txt files
C0014E117.txt C0016E117.txt C0015E117.txt C0018E117.txt C0002E117.txt C0003E117.txt C0014j11.txt C0015j11.txt C0016j11.txt C0014f11.txt C0015f11.txt C0016f11.txt What I need to do is merge each bach of files with the same questions. So I am looking to do a function that checks for the first number before the letter so i get. E117.txt j11.txt f11.txt The above function does this on my local dir but when I map to the network I get a problem Thanks |
|
#4
|
|||
|
|||
|
Since you can't (or won't) elaborate on what you mean by "I get a problem" all I can do is offer sympathy and encouragement in your debugging efforts.
|
|
#5
|
|||
|
|||
|
sorry,
Code:
Y = Len(filename)- Len(strDirectory)+1
For i =y To Len(filename)
x = Mid(filename, i, i + 1)
'wscript.echo "Current x: " & x
If Asc(x) >= 65 Then
position = i
Exit For
End If
Next
findquestion = Right(filename, Len(filename) - (position) + 1)
end function
I the function above works fine on my local dir strDirectory = "c:\input\" filename =c:\input\P0012E117.txt when it goes through the function returns E117.txt if the txt file was H45000k45.txt it would return k45.txt When I map to the network strDirectory ="\\the-mapps-ht04\mysdata\ghai56\internal holding\Input Files2\" filename="\\the-mapps-ht04\mysdata\ghai56\internal holding\Input Files2\P0012E117.txt" gives filename="\\the-mapps-ht04\mysdata\ghai56\internal holding\Input Files2\P0012E117.txt" instead of just E117.txt so the problem I am not sure why I get the wrong results when I map to the network using the same function. |
|
#6
|
||||
|
||||
|
your logic is flawed, only by chance you didn't discover it earlier.
it got nothing to do with network files, it would fail on any file name long enough in specific format. here is correct function, changes are highlighted in blue: Code:
Function FindQuestion(filename, strDirectory) Dim Y, x, position Dim i Y = Len(filename)- Len(strDirectory) position = 0 For i=(Len(filename)-Y+2) To Len(filename) x = Mid(filename, i, i + 1) If Asc(x) >= 65 Then position = i Exit For End If Next FindQuestion = Right(filename, Len(filename) - (position) + 1) End Function |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > File problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|