You have to do your VAR statements before anything else.

Try it this way:

function pad(str, length, padChar) {
 var strLen = len(trim(str));
 var difference = length - strLen;

 str = trim(str);
 if (strLen GT length) {
        ....

Shawn Grover

-----Original Message-----
From: Jamie Jackson [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, March 12, 2002 12:27 PM
To: CF-Talk
Subject: What's wrong with this simple UDF?


function pad(str, length, padChar) {
 str = trim(str);
 var strLen = len(str);//<--##This is the error line##
 var difference = length - strLen;

 if (strLen GT length) {
  newStr = str;
 } else {
  newStr = str & repeatstring(padChar, difference);
 }
 return newstr;
}

Here's the error I'm getting:
==========
Just in time compilation error
Invalid parser construct found on line 8 at position 2. ColdFusion was
looking at the following text:
var
Invalid expression format. The usual cause is an error in the
expression structure.
==========

BTW, it doesn't seem to help do declare:
var strLen = '';
strLen =  trim(str);

Thanks,
Jamie

______________________________________________________________________
Dedicated Windows 2000 Server
  PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
  Instant Activation · $99/Month · Free Setup
  http://www.pennyhost.com/redirect.cfm?adcode=coldfusiona
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to