Charles,

Use these links to help you out (from the CFDocs):
http://localhost/cfdocs/CFML_Language_Reference/
    3_ColdFusion_Functions/lr3_003.htm#1258462
    3_ColdFusion_Functions/lr3_011.htm#1138964

Good candidate for a custom tag (maybe there already is one for this)


<!---ArrayReverse.cfm--->
<!---Build new array and decide on how many elements--->
<CFSET Ary = ArrayNew(1) />
<CFSET NumOfElements = 9 />

<!---populate array with values and display them--->
<CFLOOP index="i" from="1" to="#NumOfElements#">
    <CFSET Ary[i]=i^2 />
    <CFOUTPUT>#Ary[i]#</CFOUTPUT><br />
</CFLOOP>
<br />

<!---get length of array and the midpoint (fixed)--->
<CFSET AryLen = ArrayLen(Ary) />
<CFSET Midpoint = Fix(AryLen/2) />

<!---Loop only to midpoint, everthing will be swapped then--->
<CFLOOP index="i" from="1" to="#midpoint#">
    <CFSET temp = ArraySwap(Ary, i, AryLen-i+1) />
</CFLOOP>

<!---display new swapped array--->
<CFLOOP index="i" from="1" to="#NumOfElements#">
    <CFOUTPUT>#ary[i]#</CFOUTPUT><br />
</CFLOOP>



David L. Penton
"Mathematics is music for the mind, and Music is Mathematics for the
Soul." - J.S. Bach
[EMAIL PROTECTED]

  "If you want an ISP with great Network
   connectivity and great email,
   DON'T use AT&T @Home"


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
Behalf Of Charles Crittenden Jr.
Sent: Friday, February 23, 2001 3:18 PM
To: [EMAIL PROTECTED]
Subject: Re: Printing an array


Ok
I am sorry I was not specific on what I was asking I
am really try to reverse the order of the array for
example. If my array was stored
1
2
3
4
5
6
I want to revearse the way it is stored to
6
5
4
3
2
1
I know there is some javascript I can run called array
reverse.  But is there another way to handle this
--- "Adrian J. Moreno" <[EMAIL PROTECTED]>
wrote:
> I believe this will do:
>
> <cfloop index="i" from="3" to="6">
> <cfoutput>#myArray[i]#<br></cfoutput>
> </cfloop>
>
> HTH,
>
> Adrian J. Moreno
>
> "Charles Crittenden Jr." wrote:
>
> > I am trying to print the contents of an array.
> For
> > example I want to print from postion 3 to postion
> 6 in
> > a one-dimensional array with 9 elements inside of
> the
> > array.  Is there a fucntion I can use to handle
> this
> > situation?
> >
> > Charles


-------------------------------------------------------------------------
This email server is running an evaluation copy of the MailShield anti-
spam software. Please contact your email administrator if you have any
questions about this message. MailShield product info: www.mailshield.com

-----------------------------------------------
To post, send email to [EMAIL PROTECTED]
To subscribe / unsubscribe: http://www.dfwcfug.org

Reply via email to