How do you write or read to external files with custom extensions (like, instead of a .txt extension it could have .cyc for example) using VBscript?
I don’t know how, and cannot seem to figure it out. For reading a file, is it possible to only read part of a file? For example, if I have a line
string1=Hello World!
inside of my file, how does my script only read from the string1 line and how can it assign the text value to a string in the vbscript file?
Then, how can I write a single value to my file?
To clarify, I am basically attempting to use external files as configuration/data files.
This is probably a really nooby question, and I am really sorry if it is.
EDIT: This is a two part question, I need to know the code to read and write files as specified above, and how to use custom extensions with it.
If you want to read and write from the text file at random locations, your best bet is to use INI files.
An INI file contains entries that look like this:
To read an ini file, you need a function that you can call like this:
…which will put “John Doe” in s.
The code to do this is here:
http://cwashington.netreach.net/depo/view.asp?Index=553
Writing the INI file works the same way.
Here is another example:
creates an INI file that looks like this:
You can have as many different sections and items within each section as you want. All you have to do to retrieve the value that you want is to call ReadINI with the section name and item name of the value you want to retrieve.