The still get the same error "Parameter 2 of function Left which is now
-1 must be a positive integer"

OK here is the pair of UDFs if anyone cares to play with them.  All they
are meant to do is to encode a value to a short non readable string.  I
plan to use to encode url vars when security is not major issue. Simply
this is meant to be generate a short sneaky, not secure encoded string.

As you can see buy the qencode function a random number is added to the
end of the sting just to make it look non-sequestional when a list of
the code are viewed.  All I am trying to do is to trim that last number
off on the qdecode output.

Thanks for your help.

<cfscript>

function qencode(urlvars){

            var tempurlvars = URLEncodedFormat(urlvars  & RandRange(0,
9));

            var strlen = len(tempurlvars);

            var newstr = "";

            var tempstr = "";

            var i = 1;

            var key = 65;

            for(i=1;i lte strlen;i=i+1) {

                        tempstr = Asc(Mid(tempurlvars, i, 1));

                        

                        newstr = newstr & Chr(tempstr + 3);

                        

            }

            return URLEncodedFormat(newstr);

}

</cfscript>

<cfscript>

function qdecode(urlvars){

            var tempurlvars = URLDecode(urlvars);

            

            var strlen = len(tempurlvars);

            var newstr = "";

            var tempstr = "";

            var i = 1;

            for(i=1;i lte strlen;i=i+1) {

                        tempstr = Asc(Mid(tempurlvars, i, 1));

                        

                        newstr = newstr & Chr(tempstr - 3);

    }

               strReturn = 'Too Short:' & newstr & ':end';

   if (len(newstr)+1)

    strReturn = left(newstr,len(newstr)-1);

            

            return strReturn;

}

</cfscript>

Mark W. Breneman
-Cold Fusion Developer
-Network Administrator
  Vivid Media
  [EMAIL PROTECTED]
  www.vividmedia.com
  608.270.9770

-----Original Message-----
From: Calvin Ward [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 08, 2003 3:16 PM
To: CF-Talk
Subject: Re: Ok, I give up UDF error

What does this do for you?

<cfscript>
function qdecode(urlvars){
            var tempurlvars = URLDecode(urlvars);
            var strlen = len(tempurlvars);
            var tempstr = "";
            var i = 1;
            var newstr = "";
            for(i=1;i lte strlen;i=i+1) {
                        tempstr = Asc(Mid(tempurlvars, i, 1));         
                        newstr = newstr & Chr(tempstr - 3);
            }
   strReturn = 'Too Short:' & newstr & ':end';
   if (len(newstr)+1)
    strReturn = left(newstr,len(newstr)-1);
    }
</cfscript>

- Calvin
  ----- Original Message -----
  From: Mark W. Breneman
  To: CF-Talk
  Sent: Wednesday, October 08, 2003 3:52 PM
  Subject: RE: Ok, I give up UDF error

  Good question, but no, I have ran the output several times and checked
  all values none are blank.

  Mark W. Breneman
  -Cold Fusion Developer
  -Network Administrator
    Vivid Media
    [EMAIL PROTECTED]
    www.vividmedia.com
    608.270.9770

  -----Original Message-----
  From: Matthew Walker [mailto:[EMAIL PROTECTED]
  Sent: Wednesday, October 08, 2003 2:44 PM
  To: CF-Talk
  Subject: Re: Ok, I give up UDF error

  Is your input string empty?
    ----- Original Message -----
    From: Mark W. Breneman
    To: CF-Talk
    Sent: Thursday, October 09, 2003 8:37 AM
    Subject: Ok, I give up UDF error

    This seems so simple. All I want to do is to trim the last char from
  the
    return string.  I keep getting this error "Parameter 2 of function
  Left
    which is now -1 must be a positive integer"

    If I hard code a value in the UDF works with out a problem.  But
when
  I
    put in the len(newstr)-1  into the "left" function it seems to
  evaluate
    to 0.

    Can anyone help me out?

    <cfscript>

    function qdecode(urlvars){

                var tempurlvars = URLDecode(urlvars);

                var strlen = len(tempurlvars);

                var tempstr = "";

                var i = 1;

                var newstr = "";

                for(i=1;i lte strlen;i=i+1) {

                            tempstr = Asc(Mid(tempurlvars, i, 1));

                            newstr = newstr & Chr(tempstr - 3);

                }

                return left(newstr,len(newstr)-1);

    }

    </cfscript>

    Mark W. Breneman

    -Cold Fusion Developer

    -Network Administrator

      Vivid Media

      [EMAIL PROTECTED]

      www.vividmedia.com

      608.270.9770

    _____  


  _____  


[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to