Basic HTML version of Foils prepared 23 June 1997

Foil 42 JavaScript String Objects - II

From JavaScript Tutorial for Certificate Course UC Web applications Certificate -- Summer 97. by Geoffrey C. Fox, Tom Scavo


/* Given two linked comma-separated strings containing parameter
names and values for an applet, return the corresponding HTML */
function commaseparated(appletpname,appletpvalue) {
var stop = appletpname.lastIndexOf(','); // last comma
if( appletpname.length <= 0 )
stop = -2; // length is property of String object
index = -1;
var ct = 0; // this is a precaution
var jndex1 = 0;
var jndex = -1;
while( index <= stop) { // scan through commas
index1 = appletpname.indexOf(',', index+1); // next comma
if (index1 < 0 ) index1 = appletpname.length; // no more commas
++ct;
if ( ct > 20 ) break;
jndex1 = appletpvalue.indexOf(',', jndex+1);
if ( jndex1 < 0 ) jndex1 = appletpvalue.length;
// Extract the stuff between commas
var grab1 = appletpname.substring(index+1, index1);
var grab2 = appletpvalue.substring(jndex+1, jndex1);
var tag = '<param name=' + grab1 + ' value="' + grab2 + '">';
top.document.writeln(tag);
index = index1;
jndex = jndex1;
}
}



Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Wed Apr 1 1998