Help Please array fixes needed

S

Suzanne Saville

The code is below. I've tried many things but I need to reverse the
array, and also in the message is it contains an & # % it cuts the
rest of the message off. Please help.

JS included script
------------------
// *** Start of Server-inserted script ***

function getURL () { return '<CTX_VAL URL>'; }
function getImageRoot () { return '<CTX_VAL ImageRoot>'; }
function getDocRoot () { return '<CTX_VAL DocRoot>'; }

function doPost ( pageFmt, cmdFmt ) { window.location.replace (
getURL() + pageFmt + cmdFmt ); }

arryUnicode = new Array("0", "1", "2", "3", "4", "5", "6", "7", "8",
"9", "A", "B", "C", "D", "E", "F");
function doConvertUnicode(code) {
d = parseInt(code / 16, 10);
m = code % 16;
return "00" + arryUnicode[d] + arryUnicode[m];
}

// format arguments from an array (such as an argument list).
//Offset and length specify
// where, in the args array, to start and how many to use.
function formatArgs ( argPrefix, args, offset, length )
{
var argText = '';
for (var i=0; i<length; i++) {
var newvalue = "";
for (var j=0; j<args[offset+i].length; j++) {
if (args[offset+i].charCodeAt(j) > 127 ||
args[offset+i].charCodeAt(j) < 30) {
newvalue += "\\u" +
doConvertUnicode(args[offset+i].charCodeAt(j));
}
else {
newvalue += args[offset+i].charAt(j);
}
}
args[offset+i] = newvalue;
argText += argPrefix + (i+1) + '=' + args[offset+i];


}

return argText;

}
function formatPageArgs ( args, offset, length ) { return formatArgs (
'&pa', args, offset, length ); }
function formatCmdArgs ( args, offset, length ) { return formatArgs (
'&ca', args, offset, length ); }

function jPage ( page ) { return '&pi=' + page + formatPageArgs (
jPage.arguments,1, jPage.arguments.length-1 ); }
function jCmd ( cmd ) { return '&ci=' + cmd + formatCmdArgs (
jCmd.arguments,1, jCmd.arguments.length-1 ); }

function formatPage ( page, formattedArgs ) { return '&pi=' + page +
formattedArgs; }
function formatCmd ( cmd, formattedArgs ) { return '&ci=' + cmd +
formattedArgs; }

// Requests a new page. Arguments following "page" are used as page
arguments.
function newPage ( page ) { doPost ( formatPage ( page, formatPageArgs
( newPage.arguments,1, newPage.arguments.length-1 ) ), '' ); }

// Issues a command, formatted per formatCmd.
function doFormattedCommand ( formattedCmd ) { doPost ( '',
formattedCmd ); }

// Issues a command. Arguments following "cmd" are used as command
arguments.
function doCommand ( cmd )
{
doPost ( '', formatCmd ( cmd, formatCmdArgs ( doCommand.arguments,
1, doCommand.arguments.length-1 ) ) );
}

// Issues a command AND requests a new page. No page arguments are
permitted.
// Arguments following "cmd" are used as command arguments.
function doCmdAndNewPage ( page, cmd )
{
var formattedArgs = formatCmdArgs ( doCmdAndNewPage.arguments, 2,
doCmdAndNewPage.arguments.length-2 );
doPost ( jPage ( page ), formatCmd ( cmd, formattedArgs ) );
}


Program call
------------

function doSendMsgAll() {
var args = new Array();
with(document.chatForm) {
args[0] = newMsg.value;

}

doFormattedCommand( formatCmd( 'SendMsg', formatCmdArgs( args, 0,
args.length)));
}
 
D

Dr John Stockton

JRS: In article <[email protected]>, seen
The code is below. I've tried many things but I need to reverse the
array, and also in the message is it contains an & # % it cuts the
rest of the message off. Please help.

You have posted code which your sending software has been allowed to
line-wrap. This makes it unnecessarily difficult to read.

Code should not be wrapped, except by someone who understands the
intention - which may not match the code.

Either set a wide-enough right margin (and hand-wrap any paragraphs of
text), or write the code within a margin no wider than your browser's.
I currently code to within a 68-character margin.

By being seen to have taken the trouble to make your code easy to read,
you can encourage others to give attention to it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,099
Messages
2,570,626
Members
47,237
Latest member
David123

Latest Threads

Top