This is what I have for str_pad:

function strPad(str, length, char) // based on PadString from
cflib.org by Rob Brooks-Bilson ([EMAIL PROTECTED])
{
  var pad = repeatString(char, length);
  return str & pad;
}

This is what I did for A = array(1732584193, 4023233417, 2562383102,
271733878, 3285377520);

A = arrayNew(1);
A[1] = 1732584193;
A[2] = 4023233417;
A[3] = 2562383102;
A[4] = 271733878;
A[5] = 3285377520;

and this for list(a,b,c,d,e)=A;

a = A[1];
b = A[2];
c = A[3];
d = A[4];
e = A[5];

I am concerned that I will have to go through and change all of the
lower case "a"'s in the function to something else since CFSCRIPT is
case-insensitive and will treat my array "A" the same as the variable
"a".

The PHP list() function doesn't just create a list as would be
expected. Instead, it assigns each variable in the list (a,b,c,d,e) a
value corresponding with the values in the array. that is why there is
an equals operator after the function.

I still need to figure out a replacement for the array_values() and
unpack() PHP functions.

It's coming along though, I think.

-Aaron

On 11/9/06, Bobby Hartsfield <[EMAIL PROTECTED]> wrote:
> Try repeatstring() for your padding. A function shouldn't be to hard to
> write for that though to make it easier. Here's a shot at one....
>
> <cfscript>
> function str_pad (str1, str2, count, dir)
> {
>
>         validDirections = "left,rigtht,r,l,both";
>         newstr = '';
>         if(dir is 'left' or dir is 'l')
>         {
>                 //pad the left
>                 newstr = repeatstring(str2, count) & str1;
>         }
>         else if (dir is 'right' or dir is 'r')
>         {
>                 // padd the rirght
>                 newstr = str1 & repeatstring(str2, count);
>         }
>         else
>         {
>                 //pad both sides
>                 newstr = repeatstring(str2, count) & str1 &
> repeatstring(str2, count);
>         }
>         return newstr;
>
> }
> </cfscript>
>
> <cfoutput>
>
> [#str_pad ('Alien', '&nbsp;', 10, 'right')#]<br>
> [#str_pad ('Alien', '-=', 10, 'left')#]<br>
> [#str_pad ('Alien', '_', 10, 'both')#]<br>
> [#str_pad ('Alien', '_', 6, 'right')#]<br>
> <hr>
> [Alien#repeatstring('&nbsp;', 10)#]<br>
> [#repeatstring('-=', 10)#Alien]<br>
> [#repeatstring('_', 10)#Alien#repeatstring('_', 10)#]<br>
> [#repeatstring('_', 6)#Alien]<br>
>
> </cfoutput>
>
>
>
>
> As for the    A = array(1732584193, 4023233417, 2562383102,  271733878,
> 3285377520);
>
>
> <cfset a = arraynew(1) />
> <cfset a[1] = '1732584193' />
> <cfset a[2] = '4023233417' />
> <cfset a[3] = '2562383102' />
> <cfset a[4] = '271733878' />
>
> ....would make an array with the same values
>
> list(a,b,c,d,e)=A;
>
> that would just be...
>
> <cfset a = "a,b,c,d,e" />
>
>
>
>
> -----Original Message-----
> From: Aaron Roberson [mailto:[EMAIL PROTECTED]
> Sent: Thursday, November 09, 2006 7:44 PM
> To: CF-Talk
> Subject: Re: Help Converting PHP page to ColdFusion
>
> Thanks Andrew, I will try your struct example.
>
> Do you have any ideas regarding str_pad()
>
> It takes three arguments, 1)the string to pad 2) the pad length and 3)
> the padding
>
> What it does is pad the string on the right with the specified padding
> at the specified length. Here is an example from the manual:
>
> <?php
> $input = "Alien";
> echo str_pad($input, 10);                      // produces "Alien    "
> echo str_pad($input, 10, "-=", STR_PAD_LEFT);  // produces "-=-=-Alien"
> echo str_pad($input, 10, "_", STR_PAD_BOTH);  // produces "__Alien___"
> echo str_pad($input, 6 , "___");              // produces "Alien_"
> ?>
>
> -Aaron
>
> On 11/9/06, Andrew Scott <[EMAIL PROTECTED]> wrote:
> > Ok I haven't an idea of the top of my head, but you would need to loop
> over
> > the lsit and store in a struct
> >
> > or
> >
> > mystruct = structnew
> > mystruct.a = listgetat(list,1);
> > mystruct.b = listgetat(list,2);
> > mystruct.c = listgetat(list,3);
> >
> > Now if you really wanted to be creative yo could create a UDF to pass the
> > string and loop through and do this but natively no CF doesn't have this.
> >
> >
> > On 11/10/06, Aaron Roberson <[EMAIL PROTECTED]> wrote:
> > >
> > > A = array(1732584193, 4023233417, 2562383102,  271733878, 3285377520);
> > > list(a,b,c,d,e)=A;
> > >
> > > I added
> > > A = arrayNew(1);
> > > above this block of code.
> > >
> > > The first line of code is assigning the values to the array. The
> > > second line of code uses the list() function to assing each value in
> > > the array to the keys a,b,c,d,e so the result is this:
> > > a = 1732584193
> > > b = 4023233417
> > > c = 2562383102
> > > d = 271733878
> > > e = 3285377520
> > >
> > > It should be simple to do in ColdFusion but I can't think of the
> solution.
> > >
> > > -Aaron
> > >
> > > On 11/9/06, Andrew Scott <[EMAIL PROTECTED]> wrote:
> > > > Aaron not to be able to answer all your questions but a constant is a
> > > > variable that does not change hence why they call it a constant
> > > variable.
> > > >
> > > > So in answer to you there
> > > >
> > > > <cfif isDefined('Varaible') />
> > > >
> > > > Would check for the existance of that variable, the other way is
> > > >
> > > > <cfparam name="Variable" default="hello" />
> > > >
> > > > This would also check the existance of a variable, but it will assign
> it
> > > a
> > > > default value as well.
> > > >
> > > > Now I am sure cyba_sha1 is a MD5 hashing encryption so you might look
> at
> > > the
> > > > function has on coldfusion.
> > > >
> > > > Not sure what this does
> > > > A = array(1732584193, 4023233417, 2562383102,  271733878, 3285377520);
> > > > list(a,b,c,d,e)=A; so can't answer you there.
> > > >
> > > > and strpad you might go to udf.com I think it is  for string
> > > manipulation
> > > > code.
> > >
> > >
> >
> >
>
>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:259865
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to