Re: Arrays and Structures storing query values

2001-04-30 Thread stas

It looks like you have to do StructNew within the loop for every iteration.
In your code you are only doing that once, for the first array element.

- Original Message -
From: Darren Adams [EMAIL PROTECTED]


!--- query the old newsroom database---

cfquery name=news datasource=newsadmin dbtype=ODBC
select * from pressreleasetable
ORDER by pressreleasedate DESC
/cfquery

!---Setup an array with a structure ---

cfset oldnews = ArrayNew()
cfset oldnews[1] = StructNew()
!---add others here later e.g. prsub,prcontent,date etc... ---

Cfoutput query=news
cfset oldnews[news.currentrow].headline = #pressreleaseheader#
/cfoutput



~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



RE: Arrays and Structures storing query values

2001-04-30 Thread Neil Clark

I think you need to do it the other wat around - Structures can hold arrays,
I dont think arrays can store structures.

N

!-
Neil Clark
Senior Web Applications Engineer
XML / Cerebro
MCB Digital
Macromedia Alliance Member
Tel: 020 8941 3232
Fax: 020 8941 4333
e-mail: [EMAIL PROTECTED]




~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



RE: Arrays and Structures storing query values

2001-04-30 Thread Darren Adams

According to the official Advanced Coldfusion Development course book you
can.

-Original Message-
From: Neil Clark [mailto:[EMAIL PROTECTED]]
Sent: 30 April 2001 16:10
To: CF-Talk
Subject: RE: Arrays and Structures storing query values


I think you need to do it the other wat around - Structures can hold arrays,
I dont think arrays can store structures.

N

!-
Neil Clark
Senior Web Applications Engineer
XML / Cerebro
MCB Digital
Macromedia Alliance Member
Tel: 020 8941 3232
Fax: 020 8941 4333
e-mail: [EMAIL PROTECTED]

~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



RE: Arrays and Structures storing query values

2001-04-30 Thread Aaron Johnson

Sure they can Neil,

cfscript
myArray = arraynew(1);
myArray[1].myStruct = structnew();
myArray[1].myStruct.name = Aaron;
/cfscript

Works for me.

Aaron Johnson, MCSE, MCP+I
Allaire Certified ColdFusion Developer
MINDSEYE, Inc.
phn617.350.0339
fax617.350.8884
icq66172567
[EMAIL PROTECTED] 


 -Original Message-
 From: Neil Clark [mailto:[EMAIL PROTECTED]]
 Sent: Monday, April 30, 2001 11:10 AM
 To: CF-Talk
 Subject: RE: Arrays and Structures storing query values
 
 
 I think you need to do it the other wat around - Structures can 
 hold arrays,
 I dont think arrays can store structures.
 
 N
 
 !-
 Neil Clark
 Senior Web Applications Engineer
 XML / Cerebro
 MCB Digital
 Macromedia Alliance Member
 Tel: 020 8941 3232
 Fax: 020 8941 4333
 e-mail: [EMAIL PROTECTED]
 
 
 
 

~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



RE: Arrays and Structures storing query values

2001-04-30 Thread Raymond Camden

 MacroMedia Representitive 
Arrays can store structs.

CFSET X = ArrayNew(1)
CFSET X[1] = StructNew()

You can get crazy if you want.

CFSET X[1].Y = ArrayNew(1)
CFSET X[1].Y[1] = StructNew()
CFSET X[1].Y[1][unreadable] = Yes

===
Raymond Camden, Principal Spectra Compliance Engineer for Macromedia

Email   : [EMAIL PROTECTED]
ICQ UIN : 3679482

My ally is the Force, and a powerful ally it is. - Yoda 

 -Original Message-
 From: Neil Clark [mailto:[EMAIL PROTECTED]]
 Sent: Monday, April 30, 2001 11:10 AM
 To: CF-Talk
 Subject: RE: Arrays and Structures storing query values
 
 
 I think you need to do it the other wat around - Structures can 
 hold arrays,
 I dont think arrays can store structures.
 
 N


~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



Re: Arrays and Structures storing query values

2001-04-30 Thread Gerry Pauline

Darren:

I'm just starting to use structures in CF too, so I'm by no means an
expert, but the code appended below is what I've used to address the
task you asked about -- hope it helps !

-Gerry

Gerard T. Pauline
Mgr, Internet/DB Applications
Computer Systems, DoIT
Pace University



CFQUERY NAME=Info DATASOURCE=LSN  MAXROWS=100

SELECT student_ID, last_name, first_name 
FROM Students
ORDER BY last_name, first_name;

/CFQUERY

CFSET Student = ArrayNew(1)
CFSET Idx = 0

CFLOOP QUERY=Info
CFSET Idx = Idx + 1 
CFSET Student[Idx]= StructNew()
CFSET Student[Idx].ID = Info.Student_ID
CFSET Student[Idx].LN = Info.Last_Name
CFSET Student[Idx].FN = Info.First_Name
/CFLOOP

TABLE BORDER=3
CFOUTPUT
CFLOOP INDEX=T FROM=1 TO=#ArrayLen(Student)#
CFIF Student[T].ID GTE 90
TR
TD#Student[T].ID#/TD
TD#Student[T].LN#/TD
TD#Student[T].FN#/TD
/TR
/CFIF
/CFLOOP
/CFOUTPUT
/TABLE




Darren Adams wrote:
 
 Can anyone lend me a hand ?
 
 I am trying to store one database in an array of structures then insert it
 into another database.
 
 I am only using one field at the moment but, there will be 9 that I want to
 copy over.
 
 What I am trying to do is to take PressReleaseHeader from the
 pressreleasetable.
 
 But it keep giving me errors.
 
 !--- query the old newsroom database---
 
 cfquery name=news datasource=newsadmin dbtype=ODBC
 select * from pressreleasetable
 ORDER by pressreleasedate DESC
 /cfquery
 
 !---Setup an array with a structure ---
 
 cfset oldnews = ArrayNew()
 cfset oldnews[1] = StructNew()
 !---add others here later e.g. prsub,prcontent,date etc... ---
 
 Cfoutput query=news
 cfset oldnews[news.currentrow].headline = #pressreleaseheader#
 /cfoutput
 
 Darren Adams
 Web Developer
 Marketing Department
 Systems Union
 
 Office: 01252 55 6220
 Mobile: 07714 817 038
 Email: [EMAIL PROTECTED]
 

~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



RE: Arrays and Structures storing query values

2001-04-30 Thread Steve Martin

!--- query the old newsroom database---

cfquery name=news datasource=newsadmin dbtype=ODBC
select * from pressreleasetable
ORDER by pressreleasedate DESC
/cfquery

!---Setup an array with a structure ---

cfset oldnews = ArrayNew()
!---add others here later e.g. prsub,prcontent,date etc... ---

Cfloop query=news
cfset oldnews[news.currentrow] = StructNew()
cfloop list=#news.ColumnList# index=fieldname
cfset oldnews[news.currentrow][fieldname] = Evaluate(news. 
fieldname)
/cfloop
/cfloop

Should do the trick

Steve


 -Original Message-
 From: Darren Adams [mailto:[EMAIL PROTECTED]]
 Sent: 30 April 2001 15:28
 To: CF-Talk
 Subject: Arrays and Structures storing query values


 Can anyone lend me a hand ?

 I am trying to store one database in an array of structures then insert it
 into another database.

 I am only using one field at the moment but, there will be 9 that
 I want to
 copy over.

 What I am trying to do is to take PressReleaseHeader from the
 pressreleasetable.

 But it keep giving me errors.

 !--- query the old newsroom database---

 cfquery name=news datasource=newsadmin dbtype=ODBC
 select * from pressreleasetable
 ORDER by pressreleasedate DESC
 /cfquery

 !---Setup an array with a structure ---

 cfset oldnews = ArrayNew()
 cfset oldnews[1] = StructNew()
 !---add others here later e.g. prsub,prcontent,date etc... ---

 Cfoutput query=news
   cfset oldnews[news.currentrow].headline = #pressreleaseheader#
 /cfoutput



 Darren Adams
 Web Developer
 Marketing Department
 Systems Union

 Office: 01252 55 6220
 Mobile: 07714 817 038
 Email: [EMAIL PROTECTED]



~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



RE: Arrays and Structures storing query values

2001-04-30 Thread Robert Segal

Code should look this:

!--- query the old newsroom database---

cfquery name=news datasource=newsadmin dbtype=ODBC
select * from pressreleasetable
ORDER by pressreleasedate DESC
/cfquery

!---Setup an array with a structure ---

cfset oldnews = ArrayNew(1)
!---add others here later e.g. prsub,prcontent,date etc... ---

Cfoutput query=news
cfset oldnews[news.currentrow] = StructNew()
cfset oldnews[news.currentrow].headline = #pressreleaseheader#
/cfoutput





-Original Message-
From: stas [mailto:[EMAIL PROTECTED]]
Sent: Monday, April 30, 2001 11:00 AM
To: CF-Talk
Subject: Re: Arrays and Structures storing query values


It looks like you have to do StructNew within the loop for every iteration.
In your code you are only doing that once, for the first array element.

- Original Message -
From: Darren Adams [EMAIL PROTECTED]


!--- query the old newsroom database---

cfquery name=news datasource=newsadmin dbtype=ODBC
select * from pressreleasetable
ORDER by pressreleasedate DESC
/cfquery

!---Setup an array with a structure ---

cfset oldnews = ArrayNew()
cfset oldnews[1] = StructNew()
!---add others here later e.g. prsub,prcontent,date etc... ---

Cfoutput query=news
cfset oldnews[news.currentrow].headline = #pressreleaseheader#
/cfoutput
~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



RE: Arrays and Structures storing query values

2001-04-30 Thread Dave Watts

 I think you need to do it the other way around - Structures 
 can hold arrays, I dont think arrays can store structures.

No, arrays can contain structures, just as structures can contain arrays.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
voice: (202) 797-5496
fax: (202) 797-5444

~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



RE: Arrays and Structures storing query values

2001-04-30 Thread Darren Adams

Yep your correct !!

Also I needed to put a one in the ArrayNew() declaration.

Cheers !

-Original Message-
From: stas [mailto:[EMAIL PROTECTED]]
Sent: 30 April 2001 16:00
To: CF-Talk
Subject: Re: Arrays and Structures storing query values


It looks like you have to do StructNew within the loop for every iteration.
In your code you are only doing that once, for the first array element.

- Original Message -
From: Darren Adams [EMAIL PROTECTED]


!--- query the old newsroom database---

cfquery name=news datasource=newsadmin dbtype=ODBC
select * from pressreleasetable
ORDER by pressreleasedate DESC
/cfquery

!---Setup an array with a structure ---

cfset oldnews = ArrayNew()
cfset oldnews[1] = StructNew()
!---add others here later e.g. prsub,prcontent,date etc... ---

Cfoutput query=news
cfset oldnews[news.currentrow].headline = #pressreleaseheader#
/cfoutput
~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



RE: Arrays and Structures storing query values

2001-04-30 Thread jeff tapper

sure they can, i do it all the time.

cfset astAuthors = arrayNew(1)
cfset astAuthors[1] = structNew()
cfset astAuthors[1].firstname = 'jeff'
cfset astAuthors[1].lastname = 'tapper'
cfset astAuthors[2] = structNew()
cfset astAuthors[2].firstname = 'ben'
cfset astAuthors[2].lastname = 'forta'

works fine for me.

At 04:09 PM 4/30/01 +0100, you wrote:
I think you need to do it the other wat around - Structures can hold arrays,
I dont think arrays can store structures.

N

!-
Neil Clark
Senior Web Applications Engineer
XML / Cerebro
MCB Digital
Macromedia Alliance Member
Tel: 020 8941 3232
Fax: 020 8941 4333
e-mail: [EMAIL PROTECTED]





~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



Re: Arrays and Structures storing query values

2001-04-30 Thread Dave f

This is the CF forum, not the Spectra forum ;)

- Original Message -
From: Raymond Camden [EMAIL PROTECTED]
To: CF-Talk [EMAIL PROTECTED]
Sent: Monday, April 30, 2001 11:12 AM
Subject: RE: Arrays and Structures storing query values


  MacroMedia Representitive

 Arrays can store structs.

 CFSET X = ArrayNew(1)
 CFSET X[1] = StructNew()

 You can get crazy if you want.

 CFSET X[1].Y = ArrayNew(1)
 CFSET X[1].Y[1] = StructNew()
 CFSET X[1].Y[1][unreadable] = Yes

 ===
 Raymond Camden, Principal Spectra Compliance Engineer for Macromedia

 Email   : [EMAIL PROTECTED]
 ICQ UIN : 3679482

 My ally is the Force, and a powerful ally it is. - Yoda

  -Original Message-
  From: Neil Clark [mailto:[EMAIL PROTECTED]]
  Sent: Monday, April 30, 2001 11:10 AM
  To: CF-Talk
  Subject: RE: Arrays and Structures storing query values
 
 
  I think you need to do it the other wat around - Structures can
  hold arrays,
  I dont think arrays can store structures.
 
  N



~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



RE: Arrays and Structures storing query values

2001-04-30 Thread Neil Clark

Doh.  Just think the other way around is more suited? maybe not?
whatdoiknow!!! :-(

!-
Neil Clark
Senior Web Applications Engineer
XML / Cerebro
MCB Digital
Macromedia Alliance Member
Tel: 020 8941 3232
Fax: 020 8941 4333
e-mail: [EMAIL PROTECTED]




~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



RE: Arrays and Structures storing query values

2001-04-30 Thread Darren Adams

Yep !
Thats the fella 

-Original Message-
From: Robert Segal [mailto:[EMAIL PROTECTED]]
Sent: 30 April 2001 16:20
To: CF-Talk
Subject: RE: Arrays and Structures storing query values


Code should look this:

!--- query the old newsroom database---

cfquery name=news datasource=newsadmin dbtype=ODBC
select * from pressreleasetable
ORDER by pressreleasedate DESC
/cfquery

!---Setup an array with a structure ---

cfset oldnews = ArrayNew(1)
!---add others here later e.g. prsub,prcontent,date etc... ---

Cfoutput query=news
cfset oldnews[news.currentrow] = StructNew()
cfset oldnews[news.currentrow].headline = #pressreleaseheader#
/cfoutput





-Original Message-
From: stas [mailto:[EMAIL PROTECTED]]
Sent: Monday, April 30, 2001 11:00 AM
To: CF-Talk
Subject: Re: Arrays and Structures storing query values


It looks like you have to do StructNew within the loop for every iteration.
In your code you are only doing that once, for the first array element.

- Original Message -
From: Darren Adams [EMAIL PROTECTED]


!--- query the old newsroom database---

cfquery name=news datasource=newsadmin dbtype=ODBC
select * from pressreleasetable
ORDER by pressreleasedate DESC
/cfquery

!---Setup an array with a structure ---

cfset oldnews = ArrayNew()
cfset oldnews[1] = StructNew()
!---add others here later e.g. prsub,prcontent,date etc... ---

Cfoutput query=news
cfset oldnews[news.currentrow].headline = #pressreleaseheader#
/cfoutput
~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



RE: Arrays and Structures storing query values

2001-04-30 Thread Raymond Camden

 MacroMedia Representitive 
Ok, I'll pick up my toys and leave then. ;)

===
Raymond Camden, Principal Spectra Compliance Engineer for Macromedia

Email   : [EMAIL PROTECTED]
ICQ UIN : 3679482

My ally is the Force, and a powerful ally it is. - Yoda 

 -Original Message-
 From: Dave f [mailto:[EMAIL PROTECTED]]
 Sent: Monday, April 30, 2001 11:35 AM
 To: CF-Talk
 Subject: Re: Arrays and Structures storing query values
 
 
 This is the CF forum, not the Spectra forum ;)
 


~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



RE: Arrays and Structures storing query values

2001-04-30 Thread Steve Martin

*** Team Pixie ***

If you think about it, arrays are suited to storing an arbitrary number of
bits of information from 1 ... n - similar to the way a table stores an
arbitrary number of records. Structures are suited to storing groups of
associated information e.g. employee=StructNew(), employee.name=bob
employee.deptNo=123, etc. in the same manner that a record uses numerous
fields to group associated information per record. Put the two together and
you get an array (or set of records) of structures (associated information).

Steve

 -Original Message-
 From: Neil Clark [mailto:[EMAIL PROTECTED]]
 Sent: 30 April 2001 16:44
 To: CF-Talk
 Subject: RE: Arrays and Structures storing query values


 Doh.  Just think the other way around is more suited? maybe not?
 whatdoiknow!!! :-(

 !-
 Neil Clark
 Senior Web Applications Engineer
 XML / Cerebro
 MCB Digital
 Macromedia Alliance Member
 Tel: 020 8941 3232
 Fax: 020 8941 4333
 e-mail: [EMAIL PROTECTED]
 




~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



Re: Arrays and Structures storing query values

2001-04-30 Thread Joshua Meekhof

Darren,

Try looking at the problem differently.  You can treat your query as
structure of arrays.  If you do this you won't have to do any conversion
at all.  Simply set up a for () or cfloop from to index loop and out
put only the values you want.

cfloop from=1 to=#news.recordcount# index=i
headline = news['headline'][i];
// do something
/cfloop

--
Josh Meekhof

~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists