Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org

Feedback on: irt.org FAQ Knowledge Base Q585, January 15, 2002 at 12:48:37:

You are here: irt.org | About | Feedback | 3492 [ previous next ]

Feedback on:
irt.org FAQ Knowledge Base Q585

Sent by
Corvette on January 15, 2002 at 12:48:37:

Worth:
Worth reading

Comments:
1. If you enter only one line and hit "Refresh", split by "\n" does not create an array but returns the string itself, therefore textArray.length has the length of the string instead of 1.
2. If you enter less than 10 rows (the default value), testing textArray[i].length with i from 0 to rows gets you an error.

Therefore you need to modify the lines:

var textArray = text.split('\n');

if (textArray.length > rows)
rows = textArray.length;

for (var i=0; i<rows; i++)
if (textArray[i].length > cols)
cols = textArray[i].length;

with:

var textArray;
if (text.indexOf('\n') != -1) {
textArray = text.split('\n');
} else {
textArray = new Array(text);
}

if (textArray.length > rows)
rows = textArray.length;

for (var i=0; i<rows; i++)
if (i cols = textArray[i].length;



Other feedback on 'irt.org FAQ Knowledge Base Q585' - show all

©2018 Martin Webb