View Full Version : function to load files - problem with extension

03-16-2009, 08:13 PM
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))}


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

Philip M
03-16-2009, 11:55 PM

Just change txt to doc or nfo

03-17-2009, 10:41 PM
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:


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 ? :-)