[cfaussie] Re: Struct notation - whats wrong with this?
Thanks very much, Rod. /charlie -Original Message- From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Rod Higgins Sent: Monday, July 09, 2007 11:54 PM To: cfaussie@googlegroups.com Subject: [cfaussie] Re: Struct notation - whats wrong with this? Hi Charlie, I must say your Hidden Gems in CF8 is a great way to wet ones appetite on CF8. I would also like to thank you on your work with the UGTV site - it really is a wonderful resource and I would recommend all having a look. Sorry all for the cross post, I'm having issues creating new posts - I must be banned .. :) Rgds Rod --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: Struct notation - whats wrong with this?
Mike, I've got the wrong head on to day (my SQL one, the CF one is getting dusty at home) but IIRC, struct keys can't have numbers as names (at least at the start) segment[page_#counter#]thispage = counter; should work tho... On 7/10/07, Mike Kear [EMAIL PROTECTED] wrote: Ok I'm looking to see where i'm wrong here. I guess i have incorrect syntax somewhere but i dont know where, or maybe you just can't do it the way i am trying to do it ... Here's what i want to end up with - a structure with the following elements for each page: segment.1.thispage = 1; segment.1.nextpage = 2; segment.1.content = this is the content of the segment; segment.2.thispage = 2; segment.2.nextpage = 3; segment.2.content = this is the content of segment 2; The numerals in the stuct name are a variable, that changes with each iteration of the looping. So the syntax I'm using to create this structure is: segment[#counter#]thispage = counter; segment[#counter#]nextpage = (counter + 1); segment[#counter#]content = #contentelement#; But this gives me the following CF error: Invalid CFML construct found on line 239 at column 46 ColdFusion was looking at the following text: thispage So what is it objecting to? I've tried as many combinations as i can think of, without success, and i'm starting to think you can't have a variable in that location in the middle of the structure - you have to have it at the end of the element name, as in: segment.thispage[#counter#] is this correct? surely you should be able to have the second level of the name as a variable? no? -- Cheers Mike Kear Windsor, NSW, Australia Adobe Certified Advanced ColdFusion Developer AFP Webworks http://afpwebworks.com ColdFusion, PHP, ASP, ASP.NET hosting from AUD$15/month --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: Struct notation - whats wrong with this?
On Tue, Jul 10, 2007 at 12:03:26PM +1000, Mike Kear wrote: Ok I'm looking to see where i'm wrong here. I guess i have incorrect syntax somewhere but i dont know where, or maybe you just can't do it the way i am trying to do it ... Here's what i want to end up with - a structure with the following elements for each page: segment.1.thispage = 1; segment.1.nextpage = 2; segment.1.content = this is the content of the segment; segment.2.thispage = 2; segment.2.nextpage = 3; segment.2.content = this is the content of segment 2; The numerals in the stuct name are a variable, that changes with each iteration of the looping. So the syntax I'm using to create this structure is: segment[#counter#]thispage = counter; segment[#counter#]nextpage = (counter + 1); segment[#counter#]content = #contentelement#; Change this to: segment[#counter#].thispage = counter; segment[#counter#].nextpage = (counter + 1); segment[#counter#].content = #contentelement#; and it should work. Paul Haddon Technical Services Manager Formstar Print Technologies --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: Struct notation - whats wrong with this?
Mike, It is not very clear, how you have defined this. If segment is a struct, then you can't do segment[#counter#]. If it is and, segement.1 is an element of segement, then you can't use numbers as the beginning of the element name. I would have assumed that this would have been an array with structures. Andrew Scott Senior Coldfusion Developer Aegeon Pty. Ltd. www.aegeon.com.au Phone: +613 8676 4223 Mobile: 0404 998 273 -Original Message- From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Mike Kear Sent: Tuesday, 10 July 2007 12:03 PM To: cfaussie Subject: [cfaussie] Struct notation - whats wrong with this? Ok I'm looking to see where i'm wrong here. I guess i have incorrect syntax somewhere but i dont know where, or maybe you just can't do it the way i am trying to do it ... Here's what i want to end up with - a structure with the following elements for each page: segment.1.thispage = 1; segment.1.nextpage = 2; segment.1.content = this is the content of the segment; segment.2.thispage = 2; segment.2.nextpage = 3; segment.2.content = this is the content of segment 2; The numerals in the stuct name are a variable, that changes with each iteration of the looping. So the syntax I'm using to create this structure is: segment[#counter#]thispage = counter; segment[#counter#]nextpage = (counter + 1); segment[#counter#]content = #contentelement#; But this gives me the following CF error: Invalid CFML construct found on line 239 at column 46 ColdFusion was looking at the following text: thispage So what is it objecting to? I've tried as many combinations as i can think of, without success, and i'm starting to think you can't have a variable in that location in the middle of the structure - you have to have it at the end of the element name, as in: segment.thispage[#counter#] is this correct? surely you should be able to have the second level of the name as a variable? no? -- Cheers Mike Kear Windsor, NSW, Australia Adobe Certified Advanced ColdFusion Developer AFP Webworks http://afpwebworks.com ColdFusion, PHP, ASP, ASP.NET hosting from AUD$15/month No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.476 / Virus Database: 269.10.2/891 - Release Date: 8/07/2007 6:32 PM No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.476 / Virus Database: 269.10.2/891 - Release Date: 8/07/2007 6:32 PM --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: Struct notation - whats wrong with this?
Yes! thanks Paul, that did work indeed. Barry you shouldn't be at work without your CF head on. So the lesson to learn is: 1.You CAN have a struct element name that is only a numeral. 2.The square-bracket notation requires a dot after it if what follows is to be another element name 3. there is nothing in the docs about using square bracket notation in naming struct elements. Cheers Mike Kear Windsor, NSW, Australia Adobe Certified Advanced ColdFusion Developer AFP Webworks http://afpwebworks.com ColdFusion, PHP, ASP, ASP.NET hosting from AUD$15/month Change this to: segment[#counter#].thispage = counter; segment[#counter#].nextpage = (counter + 1); segment[#counter#].content = #contentelement#; and it should work. Paul Haddon Technical Services Manager Formstar Print Technologies --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: Struct notation - whats wrong with this?
So is segment an array of structs? Ie cfset segment = arrayNew(1) / cfset segument[1] = structNew() / cfset segment[1].thispage = 1 / From what you have, it looks like the numbers are structs, which doesn't make sense, the array method makes more sense. Regards Dale Fraser http://dalefraser.blogspot.com -Original Message- From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Mike Kear Sent: Tuesday, 10 July 2007 12:03 PM To: cfaussie Subject: [cfaussie] Struct notation - whats wrong with this? Ok I'm looking to see where i'm wrong here. I guess i have incorrect syntax somewhere but i dont know where, or maybe you just can't do it the way i am trying to do it ... Here's what i want to end up with - a structure with the following elements for each page: segment.1.thispage = 1; segment.1.nextpage = 2; segment.1.content = this is the content of the segment; segment.2.thispage = 2; segment.2.nextpage = 3; segment.2.content = this is the content of segment 2; The numerals in the stuct name are a variable, that changes with each iteration of the looping. So the syntax I'm using to create this structure is: segment[#counter#]thispage = counter; segment[#counter#]nextpage = (counter + 1); segment[#counter#]content = #contentelement#; But this gives me the following CF error: Invalid CFML construct found on line 239 at column 46 ColdFusion was looking at the following text: thispage So what is it objecting to? I've tried as many combinations as i can think of, without success, and i'm starting to think you can't have a variable in that location in the middle of the structure - you have to have it at the end of the element name, as in: segment.thispage[#counter#] is this correct? surely you should be able to have the second level of the name as a variable? no? -- Cheers Mike Kear Windsor, NSW, Australia Adobe Certified Advanced ColdFusion Developer AFP Webworks http://afpwebworks.com ColdFusion, PHP, ASP, ASP.NET hosting from AUD$15/month --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: Struct notation - whats wrong with this?
On Tue, Jul 10, 2007 at 12:13:56PM +1000, Mike Kear wrote: Yes! thanks Paul, that did work indeed. Good This will also work: segment[#counter#]['thispage'] = counter; segment[#counter#]['nextpage'] = (counter + 1); segment[#counter#]['content'] = #contentelement#; Extending it further you can mix arrays into it as well: segment.3.myarray = ArrayNew(1); segment.3.myarray[1] = 'a'; segment.3.myarray[2] = 'b'; segment.3.myarray[3] = StructNew(); segment.3.myarray[3].a = 'a1'; It's probably safer to use the square bracket notation, because having a numeric struct key as a child of a parent that is an array causes an error. (what?) segment.3.myarray[3].2 = 'a1'; causes an error segment.3.myarray[3][2] = 'a1'; is fine segment.3.myarray[3]['2'] = 'a1'; works as well. Now all you have to worry about is dynamically referencing deeply nested struct/array constructs.. ;) Paul Haddon Technical Services Manager Formstar Print Technologies --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: Struct notation - whats wrong with this?
Wow, I am confused, I would have expected the .thispage to be the answer. But I did not expect that an element to a structure could begin with a number. The docs have always made it clear that these had to begin with alpha characters... Who would have thought. Andrew Scott Senior Coldfusion Developer Aegeon Pty. Ltd. www.aegeon.com.au Phone: +613 8676 4223 Mobile: 0404 998 273 No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.476 / Virus Database: 269.10.2/891 - Release Date: 8/07/2007 6:32 PM --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: Struct notation - whats wrong with this?
Mike, I still don't get why you would do this when there is a perfectly good hidden feature in ColdFusion called ARRAYS. Regards Dale Fraser http://dalefraser.blogspot.com -Original Message- From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Andrew Scott Sent: Tuesday, 10 July 2007 12:45 PM To: cfaussie@googlegroups.com Subject: [cfaussie] Re: Struct notation - whats wrong with this? Wow, I am confused, I would have expected the .thispage to be the answer. But I did not expect that an element to a structure could begin with a number. The docs have always made it clear that these had to begin with alpha characters... Who would have thought. Andrew Scott Senior Coldfusion Developer Aegeon Pty. Ltd. www.aegeon.com.au Phone: +613 8676 4223 Mobile: 0404 998 273 No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.476 / Virus Database: 269.10.2/891 - Release Date: 8/07/2007 6:32 PM --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: Struct notation - whats wrong with this?
Except it is not a hidden feature. Andrew Scott Senior Coldfusion Developer Aegeon Pty. Ltd. www.aegeon.com.au Phone: +613 8676 4223 Mobile: 0404 998 273 -Original Message- From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Dale Fraser Sent: Tuesday, 10 July 2007 12:52 PM To: cfaussie@googlegroups.com Subject: [cfaussie] Re: Struct notation - whats wrong with this? Mike, I still don't get why you would do this when there is a perfectly good hidden feature in ColdFusion called ARRAYS. Regards Dale Fraser http://dalefraser.blogspot.com No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.476 / Virus Database: 269.10.2/891 - Release Date: 8/07/2007 6:32 PM --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: Struct notation - whats wrong with this?
Mike, to your point about using square bracket notation not being in the docs, are you looking only at the Reference manual? Not everything is documented there, or it can be hard to find, with its primary focus on tags and functions. But I'd be surprised if it wasn't at least covered in the Developer's Guide (the 1100+ page guide that is often missed). It's nearly 11pm here in the US, so I'll leave it to others to find where it is documented, if interested. But I really doubt it's not documented at all. /charlie Member, Adobe Community Experts program www.carehart.org My latest blog entry: Still more CFEclipse Resources --Blogsigs.com, Link your own blog posts. http://www.blogsigs.com http://carehart.org/blog/client/index.cfm/2007/7/8/still_more_cfeclipse_res ources -Original Message- From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Mike Kear Sent: Monday, July 09, 2007 10:14 PM To: cfaussie@googlegroups.com Subject: [cfaussie] Re: Struct notation - whats wrong with this? Yes! thanks Paul, that did work indeed. Barry you shouldn't be at work without your CF head on. So the lesson to learn is: 1.You CAN have a struct element name that is only a numeral. 2.The square-bracket notation requires a dot after it if what follows is to be another element name 3. there is nothing in the docs about using square bracket notation in naming struct elements. Cheers Mike Kear Windsor, NSW, Australia Adobe Certified Advanced ColdFusion Developer AFP Webworks http://afpwebworks.com ColdFusion, PHP, ASP, ASP.NET hosting from AUD$15/month Change this to: segment[#counter#].thispage = counter; segment[#counter#].nextpage = (counter + 1); segment[#counter#].content = #contentelement#; and it should work. Paul Haddon Technical Services Manager Formstar Print Technologies --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: Struct notation - whats wrong with this?
Charlie I'm sure it is documented somewhere. Those docs are very comprehensive. But right now, with a deadline against me and the search on CFDocs not bringing something up about it, I used the rather rash statement that it's not covered. I probably shouldnt have said that. As to the reason for using the numeral as the name of one of the structure elements - i used that because it's a page number. Normally i'd use a meaningful word as a variable name, but in this case it's a page number, which in the context of this task is indeed meaningful. It's part of a pagination functionality. Cheers Mike Kear Windsor, NSW, Australia Adobe Certified Advanced ColdFusion Developer AFP Webworks http://afpwebworks.com ColdFusion, PHP, ASP, ASP.NET hosting from AUD$15/month On 7/10/07, Charlie Arehart (lists account) [EMAIL PROTECTED] wrote: Mike, to your point about using square bracket notation not being in the docs, are you looking only at the Reference manual? Not everything is documented there, or it can be hard to find, with its primary focus on tags and functions. But I'd be surprised if it wasn't at least covered in the Developer's Guide (the 1100+ page guide that is often missed). It's nearly 11pm here in the US, so I'll leave it to others to find where it is documented, if interested. But I really doubt it's not documented at all. /charlie Member, Adobe Community Experts program www.carehart.org --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: Struct notation - whats wrong with this?
There is docs on it, but not about the elementname being a number:-) Not that I could find anyway. cfscript salaries = StructNew() ; employees = StructNew() ; departments = StructNew() ; for ( i=1; i lt 6; i=i+1 ) { salary = 12 - i*1 ; salaries[employee#i#] = salary ; employee = StructNew() ; employee[salary] = salary ; // employee.salary = salary ; employees[employee#i#] = employee ; departments[department#i#] = StructNew() ; departments[department#i#].boss = employee ; } /cfscript Andrew Scott Senior Coldfusion Developer Aegeon Pty. Ltd. www.aegeon.com.au Phone: +613 8676 4223 Mobile: 0404 998 273 -Original Message- From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Dale Fraser Sent: Tuesday, 10 July 2007 1:09 PM To: cfaussie@googlegroups.com Subject: [cfaussie] Re: Struct notation - whats wrong with this? What? Did you find arrays too Andrew, I thought they must have been hidden for someone to write structs such as this. I might start doing arrays like this cfset myArray = structNew() / cfset myArray['1'] = 'row 1' / cfset myArray['2'] = 'row 2' / :) Regards Dale Fraser http://dalefraser.blogspot.com -Original Message- From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Andrew Scott Sent: Tuesday, 10 July 2007 12:56 PM To: cfaussie@googlegroups.com Subject: [cfaussie] Re: Struct notation - whats wrong with this? Except it is not a hidden feature. Andrew Scott Senior Coldfusion Developer Aegeon Pty. Ltd. www.aegeon.com.au Phone: +613 8676 4223 Mobile: 0404 998 273 -Original Message- From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Dale Fraser Sent: Tuesday, 10 July 2007 12:52 PM To: cfaussie@googlegroups.com Subject: [cfaussie] Re: Struct notation - whats wrong with this? Mike, I still don't get why you would do this when there is a perfectly good hidden feature in ColdFusion called ARRAYS. Regards Dale Fraser http://dalefraser.blogspot.com No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.476 / Virus Database: 269.10.2/891 - Release Date: 8/07/2007 6:32 PM No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.476 / Virus Database: 269.10.2/891 - Release Date: 8/07/2007 6:32 PM No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.476 / Virus Database: 269.10.2/891 - Release Date: 8/07/2007 6:32 PM --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---
[cfaussie] Re: Struct notation - whats wrong with this?
Hi Charlie, I must say your Hidden Gems in CF8 is a great way to wet ones appetite on CF8. I would also like to thank you on your work with the UGTV site - it really is a wonderful resource and I would recommend all having a look. Sorry all for the cross post, I'm having issues creating new posts - I must be banned .. :) Rgds Rod -Original Message- From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Charlie Arehart (lists account) Sent: Tuesday, 10 July 2007 1:00 PM To: cfaussie@googlegroups.com Subject: [cfaussie] Re: Struct notation - whats wrong with this? Mike, to your point about using square bracket notation not being in the docs, are you looking only at the Reference manual? Not everything is documented there, or it can be hard to find, with its primary focus on tags and functions. But I'd be surprised if it wasn't at least covered in the Developer's Guide (the 1100+ page guide that is often missed). It's nearly 11pm here in the US, so I'll leave it to others to find where it is documented, if interested. But I really doubt it's not documented at all. /charlie Member, Adobe Community Experts program www.carehart.org My latest blog entry: Still more CFEclipse Resources --Blogsigs.com, Link your own blog posts. http://www.blogsigs.com http://carehart.org/blog/client/index.cfm/2007/7/8/still_more_cfeclipse _res ources -Original Message- From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Mike Kear Sent: Monday, July 09, 2007 10:14 PM To: cfaussie@googlegroups.com Subject: [cfaussie] Re: Struct notation - whats wrong with this? Yes! thanks Paul, that did work indeed. Barry you shouldn't be at work without your CF head on. So the lesson to learn is: 1.You CAN have a struct element name that is only a numeral. 2.The square-bracket notation requires a dot after it if what follows is to be another element name 3. there is nothing in the docs about using square bracket notation in naming struct elements. Cheers Mike Kear Windsor, NSW, Australia Adobe Certified Advanced ColdFusion Developer AFP Webworks http://afpwebworks.com ColdFusion, PHP, ASP, ASP.NET hosting from AUD$15/month Change this to: segment[#counter#].thispage = counter; segment[#counter#].nextpage = (counter + 1); segment[#counter#].content = #contentelement#; and it should work. Paul Haddon Technical Services Manager Formstar Print Technologies --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups cfaussie group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~--~~~~--~~--~--~---