to get a string from a notepad and use it in html

Batch, ASP, JScript, Kixtart, etc.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 15 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
shwetakannur
Posts: 2
Last visit: Mon Sep 08, 2008 10:02 pm

to get a string from a notepad and use it in html

Post by shwetakannur »

How do I get a string (randomly generated, but I do know the next line) from a .txt file and use it in html?
User avatar
shwetakannur
Posts: 2
Last visit: Mon Sep 08, 2008 10:02 pm

to get a string from a notepad and use it in html

Post by shwetakannur »

I want to know how to extract a string from a file(text file) using javascript?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

to get a string from a notepad and use it in html

Post by jvierra »

Here is an example from the WSH help file which is downloadable from Microsoft.

Code: Select all

function GetLine()
{
   var fso, f, r;
   var ForReading = 1, ForWriting = 2;
   fso = new ActiveXObject("Scripting.FileSystemObject");
   f = fso.OpenTextFile("c:testfile.txt", ForWriting, true);
   f.WriteLine("Hello world!");
   f.WriteLine("JScript is fun");
   f.Close();
   f = fso.OpenTextFile("c:testfile.txt", ForReading);
   r =  f.ReadLine();
   return(r);
}
User avatar
abqbill
Posts: 138
Last visit: Mon Sep 28, 2020 1:20 pm

to get a string from a notepad and use it in html

Post by abqbill »

Hi shwetakannur,Strictly speaking, you can't, because JavaScript/JScript has no way of directly accessing a file system (and neither does VBScript). However, as jvierra pointed out, if you are running your script in a trusted fashion (i.e., from an HTA or from a WSH script), you can use the FileSystemObject COM object to open and read from a text file.Bill
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

to get a string from a notepad and use it in html

Post by jvierra »

Hah - ust thought of another unique way to understand this message:

The original post is for "jscript" and "notepad". Perhaps the user wants to read from an open notepad instance and convert it into html using jscript. Of course the reference to Javascript adds more confusion along with the request for "randomly generated".

Is it possible that there is some kind of random string generator used for passwords or validation that produces output visible in notepad??? It would be a plain text file in any case.

No matter how I look at this request I can't make head nor tail of the question. Hmmm.
This topic is 15 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked