New Array Text Pages

Scripts by: Jenson Crawford

     Below is a description of the five scripts this page has to offer. They are very easy to use. Here's the author's explanation:


     I have attached five JavaScripts for your review for possible inclusion in your listings. All are in encapsulated in an annotated HTML file. The functions the scripts perform aren't really earth-shattering. But the internal structure differs from most JavaScripts I've seen posted.

     It seems to me that when providing scripts for downloading, that ease of use needs to be paramount. Providing a easy method for modification with minimal risk for mistakes seems a reasonable goal.

     We've all seen scripts that include code like the following:

----------------------------------------------
if (n==4) {
document.write("this is the 4th message");
}
if (n==5) {
document.write("this is the 5th message");
}
if (n==6) {
document.write("this is the 6th message");
}
----------------------------------------------

or if the script is advanced enough to use arrays:

----------------------------------------------

msg[4]="this is the 4th message";
msg[5]="this is the 5th message";
msg[6]="this is the 6th message";
----------------------------------------------

     Both methods burden the script user by making it difficult to change messages, forcing the user to be careful of numeric constant values, and often setting the size of the array. I have used a construction method to set up the arrays in a way that is much easier to modify:

----------------------------------------------
var msg = new buildArray(
"this is the 0th message",
"this is the 1st message",
"this is the 2th message",
"this is the 3th message",
"this is the 4th message",
"this is the 5th message",
"this is the 6th message"
);
----------------------------------------------

     I then use the array.length property to determine the size of the array, so the user doesn't need to worry about that.

      As I said, the functionality isn't breaking new ground, but I believe that ease of use may make the scripts worthy of inclusion in your site.

      Thank you for your consideration. And thanks again for all your hard work on the site.


     A five scripts are offered in a Zip file.

Grab the Zip file

Back to the Text-Based Scripts