SPONSORS:






User Tag List

Results 1 to 9 of 9
  1. #1
    Junior Member
    Join Date
    Apr 2000
    Location
    Cupertino,CA,95014
    Posts
    10
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to strip filename extension?

    User Edward Dias (dsd_hca@hotmail.com) posted:

    Hi all,

    I need help on how to strip file name extensions... if i have the following file names how can i remove the extension from the string?

    STRING sFileName1 = "xmlfilename.xml"
    STRING sFileName2 = "javaclass.java"

    TIA<br clear=all><hr>Get your FREE download of MSN Explorer at http://explorer.msn.com
    </p>


    [Non-text portions of this message have been removed]



  2. #2
    Senior Member
    Join Date
    Aug 1999
    Location
    Cambridge, UK
    Posts
    470
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: how to strip filename extension?

    You can use StrPos to find the position of the last full-stop in the string; you then use SubStr to grab all of the string up to this position.

    ------------------

  3. #3
    Junior Member
    Join Date
    Apr 2000
    Location
    Cupertino,CA,95014
    Posts
    10
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: how to strip filename extension?

    User Bill Watkins (wwaat@yahoo.com) posted:



    You can try this



    STRING sFileName = "myfile.xml"

    INTEGER nTemp = StrFind(sFileName,".")

    sFileName = Left(sFileName,nTemp -1)



    The syntax maybe be a little of (ie Function names) but I think it should work


    Edward Dias <dsd_hca@hotmail.com> wrote:
    Hi all,

    I need help on how to strip file name extensions... if i have the following file names how can i remove the extension from the string?

    STRING sFileName1 = "xmlfilename.xml"
    STRING sFileName2 = "javaclass.java"

    TIA<br clear=all><hr>Get your FREE download of MSN Explorer at http://explorer.msn.com
    </p>


    [Non-text portions of this message have been removed]

    Yahoo! Groups Sponsor


    Click for Details


    Post message: silktest@yahoogroups.com
    Subscribe: silktest-subscribe@yahoogroups.com
    Unsubscribe: silktest-unsubscribe@yahoogroups.com
    List owner: silktest-owner@yahoogroups.com
    URL to this page: http://groups.yahoo.com/group/silktest


    Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
    Bill Watkins

    Quality Assurance Engineer
    ---------------------------------

  4. #4
    Senior Member
    Join Date
    Mar 2001
    Posts
    161
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: how to strip filename extension?

    User Jeffry Simpson (Jsimpson@outwardtechnologies.com) posted:

    use the following string function.

    GetField(sFileName1,".",1)

    JJS

    ----- Original Message -----
    From: "Edward Dias" <dsd_hca@hotmail.com>
    To: "SilkTestGroup" <silktest@yahoogroups.com>
    Sent: Thursday, April 05, 2001 12:49 PM
    Subject: [silktest] how to strip filename extension?


    following file names how can i remove the extension from the string?



  5. #5
    Member
    Join Date
    Nov 2000
    Location
    Shelton, CT, USA
    Posts
    32
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: how to strip filename extension?

    You really should check for:
    1) Does the FileName have an extension
    2) Does the FileName have more than 1 period

    Short and quick function I use:

    Remember that StrPos() has a 3rd argument to search backwards. So using the 3rd arguments finds the last period in the string.


    [This message has been edited by mvpl (edited 04-05-2001).]

  6. #6
    Senior Member
    Join Date
    Jan 2001
    Posts
    750
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: how to strip filename extension?

    It can get conplicated:

    If you are sure that the file never gets more than 1 dot "." then

    do :
    Left(yourString,StrPos(yourString,".")-1)

    Otherwise it can be very complicated.


    ------------------

  7. #7
    Guest

    Re: how to strip filename extension?

    In your case it would be just as easy to use GetField()


    ------------------

  8. #8
    Senior Member
    Join Date
    Aug 1999
    Location
    San Diego, CA USA
    Posts
    219
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: how to strip filename extension?

    This is the reply that I sent via e-mail:

    Note that this only works for these types of filenames. If a "dot" appears more than once in the string then this will not work "as is".

    GetField is documented in the Library Browser, Functions tab, within the "String functions" group.


    ------------------

  9. #9
    Senior Member
    Join Date
    Jul 1999
    Location
    Bellingham, WA USA
    Posts
    1,323
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: how to strip filename extension?

    [This message has been edited by DJGray (edited 04-06-2001).]

    DJ, don't forget to use the [ code] and [ /code] tags. Read about UBB Code for more info

    [This message has been edited by AJ (edited 04-06-2001).]

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 03:58 AM.

Copyright BetaSoft Inc.