Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 24th, 2005, 12:16 AM
Authorized User
 
Join Date: Feb 2005
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to kumarop
Default script for substr

Hello,

How to take test.doc from string
"C:\windows\test.doc" or say from
c:\document Setting\document\test.doc
through vbscript.


regards
om prakash

om prakash kumar
__________________
om prakash kumar
 
Old March 24th, 2005, 01:09 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

Please Try:

s1 = split("c:\document Setting\document\test.doc","\")
response.write (s1(3))

Om Prakash
 
Old March 24th, 2005, 02:49 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hii KumarOp
above method is correct when you already know the directory level,
wht happend when you look for file name with
 "c:\document Setting\document\folder1\folder2\test.doc"

In this case below expression would not give you correct result.
s1 = split("c:\document Setting\document\test.doc","\")
response.write (s1(3))

There should be some generalize function ,
try this

strfile="c:\document Setting\document\test.doc"
filenamestr=getFullFileName(strfile) '// will return test.doc



function getFullFileName(strFileName)

    characterCount = Len(strFileName)
    while (nextCharacter <> "/" And characterCount > 0)
    nextCharacter = Mid(strFileName, characterCount, 1)
    if nextCharacter <> "/" Then
    newString = nextCharacter & newString
    end if
    characterCount = characterCount - 1
    wend

    getFullFileName = newString

end function


Hope this will help you

Cheers :)

vinod
 
Old March 24th, 2005, 07:18 AM
Authorized User
 
Join Date: Feb 2005
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to kumarop
Default

Hi vinod,
please see the function once again i am getting null in filenamestr in following example.


strfile = "c:\test\email\poster.doc"
filenamestr=getFullFileName(strfile)

Regards
op

om prakash kumar
 
Old March 24th, 2005, 07:24 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Om Parakash's method was much simpler, it just needed to be more general:
s1 = split("c:\document Setting\document\test.doc","\")
response.write s1(UBound(s1))
 
Old March 24th, 2005, 01:33 PM
Authorized User
 
Join Date: Feb 2005
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to kumarop
Default

Thanks guys for helps, Excellent thinking pgtips.



om prakash kumar





Similar Threads
Thread Thread Starter Forum Replies Last Post
substr from query apek PHP How-To 13 January 13th, 2004 04:16 AM
passing data and substr...HELP!!!!!!!!!!!! apek PHP How-To 1 January 11th, 2004 01:05 PM
Call and run CGI script from a PHP script ... how? dbruins BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 1 June 10th, 2003 03:09 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.