File Extension

mic1000000mic1000000 Member Posts: 12
Hi!

I'm using CodeUnit 412 for opening a openfile-dialog. How can I extract the filename (without extension) and the extension separatly?

thank you
daniel

Comments

  • KYDutchieKYDutchie Member Posts: 345
    Hi,

    If you know the extension, then it is easy.
    newfilename := COPYSTR(Filename,1,STRPOS(Filename,Extension) - 1)

    That should do it.

    Let me know if you need more help.

    Regards,

    KYDutchie
    Fostering a homeless, abused child is the hardest yet most rewarding thing I have ever done.
  • mic1000000mic1000000 Member Posts: 12
    KYDutchie wrote:
    Hi,

    If you know the extension, then it is easy.
    newfilename := COPYSTR(Filename,1,STRPOS(Filename,Extension) - 1)

    That should do it.

    Let me know if you need more help.

    Regards,

    KYDutchie

    No I don't know the extension. I'm searching for a navision function or a ocx object that can extract the name and the extension from any filename.

    thanks in advance
    daniel
  • KYDutchieKYDutchie Member Posts: 345
    Hi,

    What you could do then is take your entire string and scan backwards for the '.' character.
    FOR I = STRLEN(filename) downto 1 do BEGIN
    IF filename = '.' THEN BEGIN
    newfilename := COPYSTR(filename,1,I-1);
    I := 1;
    END;
    END;

    I don't know exactly if that is the exactly what you need, but it might put you on the right track.

    Regards,

    KYDutchie
    Fostering a homeless, abused child is the hardest yet most rewarding thing I have ever done.
  • mic1000000mic1000000 Member Posts: 12
    KYDutchie wrote:
    Hi,

    What you could do then is take your entire string and scan backwards for the '.' character.
    FOR I = STRLEN(filename) downto 1 do BEGIN
    IF filename = '.' THEN BEGIN
    newfilename := COPYSTR(filename,1,I-1);
    I := 1;
    END;
    END;

    I don't know exactly if that is the exactly what you need, but it might put you on the right track.

    Regards,

    KYDutchie

    Thanks KYDutchie!
    I know that I could do the extraction by my own but I was looking for an existent solution (build in navision or a microsoft library).
    But it looks like that there is no such thing out there. So if nobody knows something I would follow your hint.

    thank you
    Daniel
Sign In or Register to comment.