Thursday, 7 December 2017

Web Hosting Dealing with Files

When dealing with data stored in a file, you must consider where in the file the desired data is stored or where you intend to store it. You may not want to read the first three items, but you do want to read the next two items.

The file object allows you to read the current position, change the position, or check if you are at the end of the file.

Although JavaScript is still a "fledgling" language, its popularity among Web content developers is growing at an exponential rate.
Providing an easy means to extend the capability of a site without having to write extensive Java applets,JavaScript makes an effective "glue" to integrate Java, frames, and browser plug-ins into one seamless site.

Developing JavaScript-enabled content is not always a quick process. It takes some thought, some effort, and a lot of shifting from your editor to your browser… correcting some things and tweaking others.
After you design a few pages, you will develop your own system for editing and testing. The quality of the tool you use is not important; that the tool works for you is.

Like most languages, when data is sent to a file it is stored in a buffer to increase efficiencies.
This internal buffer stores the data until the buffer is full, until the file is closed, or when flushed.Then it physically writes the data into the file.

When you open a file, the current position depends on the mode you use to open it.
Generally it starts at the beginning of a file, except for modes a+ and a where data is appended at the end of an existing file. For empty or new files, the end of the file and the beginning of the file are the same.

LiveWire provides a file object which allows your application to write to the server's file system.
As a security measure, JavaScript on the browser does not permit saving data to the file system.
Like other JavaScript operations, file handling is also done using objects.

LiveWire provides a file object and you create new objects for each file you want to use. If you need to use file files, then create a new file object for each one.

After you create the file object, you then need to open the file before you can do anything else with it.
To open the file, you use the open method, as follows: ("mode")

The result is true if the file was opened successfully; otherwise it is false.

LiveWire also allows you to check on the error status of a file or clear the error status.
Since error status codes are platform dependent, you must check your operating system documentation for the actual codes. The syntax for these methods is

  • fileObj.error()
  • fileObj.clearError()

Just as there are three methods of writing to a file, so there are three methods to reading a file.
You can read a specific number of bytes, read in the entire next line, or read in a single byte. Each method returns true if successful, otherwise it returns false. The syntax is

  • fileObj.readln()
  • fileObj.readByte()

In reading a file you often want to read through the entire thing, but to do so you need to know when you have reached the end.
So you test for the end of the file (eof). The file object has the eof method that returns a true after the first read operation that attempts to read past the end of the file.

The file object provides three methods of writing data to a file. These methods allow you to write a string, write a string followed by a n , or write a single byte to a file.
Each method returns true if successful; otherwise it returns false.The syntax is

  • fileObj.write(string)
  • fileObj.writeln(string)
  • fileObj.writeByte(number)

The data in any of your files is stored in either ASCII text format or binary. The file object has two methods for converting from one format to the other.

Both methods, which follow, are static, so no object is required. The stringToByte method converts the first character of a string into a number. Characters after the first are ignored. The result is a numeric value to the first character or zero.The byteToString method converts a number into a one-character string. If the argument is not a string, the result is an empty string.

No comments:

Post a Comment

Create your online identity with business or individual website. The Join Internet list provides you the articles related to hosting site, latest hosting reviews, news and latest updates from the hosting companies.