Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question function to load files - problem with extension

    Hi guys,
    i have a function to load text files.

    function load(n){textfile=n;if(n.indexOf("#")!=-1){theleft=n.indexOf("#")+1;textfile=(n.substring(theleft))}

    document.mycall.load(textfile+'.txt');origString=textfile;

    and it only loads a files with .txt extensions.

    Could you write me please, how to change this function to load files with .doc and .nfo extensions also.

    Thank you
    kliMa

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,918
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    document.mycall.load(textfile+'.txt');origString=textfile;

    Just change txt to doc or nfo

  • #3
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thank you for your answer.

    I think that the problem of this is more complicated than I described before.

    The thing is that I need have extesnsion of the file, because without extension the file cannot be found.

    This function loads the textfile to java applet only with extension!

    So this code --> document.mycall.load(textfile+'.txt');origString=textfile;
    loads the file with *.txt extension to java applet.

    Only .txt.

    So I thought something about this like:

    document.mycall.load(textfile+'.txt');origString=textfile;
    document.mycall.load(textfile+'.doc');origString=textfile;
    document.mycall.load(textfile+'.nfo');origString=textfile;

    and it works but if I got only files with .nfo it shows that .txt and .doc cannot be found, and start to load .txt->text file.

    I tried to put IF ...else but it doesn't work, I think that the extension should be checked before it starts to load.
    like if ext='.txt' (document.mycall.load(textfile+'.txt');origString=textfile else...
    but I have no idea how to do this.

    Thank you
    any help ? :-)
    Last edited by klimauk; 03-17-2009 at 10:30 PM.


  •  

    Posting Permissions

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