Re: [cfaussie] Recursive function giving me "500 null" error
On 12 August 2010 16:27, Sean Corfield wrote: > On Wed, Aug 11, 2010 at 9:34 PM, Seona Bellamy wrote: > > > > > >... > > downTree(result); > > Bear in mind that this copies result so changes made inside downTree() > are on a copy, not the original, so after calling downTree(), result > won't have changed. > > Aha! Turns out this was the missing piece. Changing that line to: result = downTree(result); has made everything play nicely. Thanks for all the responses and clarifications. I understand what's going on better now, and why it originally screwed itself up. It was indeed caught in a never-ending loop as the first value in the array never changed and so it never got to the beginning of the tree. Cheers, Seona. -- You received this message because you are subscribed to the Google Groups "cfaussie" group. To post to this group, send email to cfaus...@googlegroups.com. To unsubscribe from this group, send email to cfaussie+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en.
Re: [cfaussie] Recursive function giving me "500 null" error
On Wed, Aug 11, 2010 at 9:34 PM, Seona Bellamy wrote: > > > ... > downTree(result); Bear in mind that this copies result so changes made inside downTree() are on a copy, not the original, so after calling downTree(), result won't have changed. -- Sean A Corfield -- (904) 302-SEAN Railo Technologies, Inc. -- http://getrailo.com/ An Architect's View -- http://corfield.org/ "If you're not annoying somebody, you're not really alive." -- Margaret Atwood -- You received this message because you are subscribed to the Google Groups "cfaussie" group. To post to this group, send email to cfaus...@googlegroups.com. To unsubscribe from this group, send email to cfaussie+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en.
Re: [cfaussie] Recursive function giving me "500 null" error
On 12/08/2010, at 4:18 PM, Robin Hilliard wrote: > structFindValue(returnValue[id], "", "all") to get an array of all the keys > under a branch of the result. Ah it's not quite right, when you first create a key in stDependencies you should set it to "", and only replace it with a struct if something makes it. Note that would only give you the raw materials, not the interim composite ones, because it would only match keys that were still = "". Robin -- You received this message because you are subscribed to the Google Groups "cfaussie" group. To post to this group, send email to cfaus...@googlegroups.com. To unsubscribe from this group, send email to cfaussie+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en.
Re: [cfaussie] Recursive function giving me "500 null" error
On 12/08/2010, at 2:34 PM, Seona Bellamy wrote: > > > > > var result = arrayNew(1); > var i = 1; > var qItem = ""; > > qItem = getItemMadeBy(aItems[1].id); > > if (qItem.recordcount) { > result[1] = structNew(); > result[1].id = qItem.id; > result[1].item = qItem.item; > result[1].skill = qItem.skillname; > result[1].makes = arguments.aItems; > > downTree(result); > } > > > > I'm sure Geoff would have something like this for Eve by now. You can see with the function above that no matter how deep you recurse there is only ever going to be an item in the first position in the array, so there's definitely a problem. You could make a build tree like this (pseudocode): function makeBuildTree() : struct { stDependencies = structNew(); for all nextItem in allItems { if not structKeyExists(stDependencies, nextItem.id) stDependencies[nextItem.id] = structNew(); for all nextMadeThing in getItemsMadeBy(nextItem.id) { if not structKeyExists(stDependencies, nextMadeThing.id) stDependencies[nextMadeThing.id] = structNew(); stDependencies[nextMadeThing.id][nextItem.id] = stDependencies[nextItem.id]; } } return stDependencies; } If you then cfdump a key in stDependencies you'd see a tree of ids showing what built what. You might then use the little known but usefuly recursive CF function structFindValue(returnValue[id], "", "all") to get an array of all the keys under a branch of the result. HTH, Robin (who should get back to some project work) ROBIN HILLIARD Chief Technology Officer ro...@rocketboots.com.au RocketBoots Pty Ltd Level 11 189 Kent Street Sydney NSW 2001 Australia Phone +61 2 9323 2507 Facsimile +61 2 9323 2501 Mobile +61 418 414 341 www.rocketboots.com.au -- You received this message because you are subscribed to the Google Groups "cfaussie" group. To post to this group, send email to cfaus...@googlegroups.com. To unsubscribe from this group, send email to cfaussie+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en.
RE: [cfaussie] Recursive function giving me "500 null" error
I'd suggest you have a recursive loop For example Let's say that Item A requires Item B And that Item B requires Item A It will go around in circles and eventually give up. Regards Dale Fraser http://dale.fraser.id.au http://cfmldocs.com <http://cfmldocs.com/> http://learncf.com http://flexcf.com From: cfaussie@googlegroups.com [mailto:cfaus...@googlegroups.com] On Behalf Of Seona Bellamy Sent: Thursday, 12 August 2010 2:34 PM To: CFAussie Subject: [cfaussie] Recursive function giving me "500 null" error Hi guys, Trying to make a little helper tool for an online game that I play. The game has a very complex crafting system, and I'm trying to put together something to allow me to select an item I can craft and find out: a) all the things I need to make that item, all the way back to the raw materials, and b) all the things I can then make from that item. I've accomplished (b) no problem. Works beautifully. I can accomplish (a) back one step. Then I try to make that recursive to step all the way back to the beginning of the sequence and it throws a "500 null" error. So I did some reading and found out that this is an error that means something has gone wrong so fundamentally early in the code that it doesn't even know how to display the error. I found a suggestion of putting a just after the application setting, but that hasn't helped. Here are the two functions at play here. If someone can give me any suggestions about what I may have done wrong, I'd be very grateful. var result = arrayNew(1); var i = 1; var qItem = ""; qItem = getItemMadeBy(aItems[1].id); if (qItem.recordcount) { result[1] = structNew(); result[1].id = qItem.id; result[1].item = qItem.item; result[1].skill = qItem.skillname; result[1].makes = arguments.aItems; downTree(result); } SELECTi.id, i.item, s.skillname FROMdi_item i INNER JOIN di_itemItem ii ON i.id = ii.madeWithID INNER JOIN di_skill s ON i.skill = s.id WHEREii.itemID = I've removed the recursive call at the end of the first function so that you can see the thing in (sort of) action at http://frontandback.com.au/DarkIsles/index.cfm?do=main.craftTree - select an item such as "a wooden spool of thick thread" (the last item in the list). It will dump out all of the things that you can make from this item, and the things you can make from those items and so on.It will also show the item that the thread is made from. What I need is for it to go multiple steps back, however. Hope this all makes sense... Cheers, Seona. -- You received this message because you are subscribed to the Google Groups "cfaussie" group. To post to this group, send email to cfaus...@googlegroups.com. To unsubscribe from this group, send email to cfaussie+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en. -- You received this message because you are subscribed to the Google Groups "cfaussie" group. To post to this group, send email to cfaus...@googlegroups.com. To unsubscribe from this group, send email to cfaussie+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en.
[cfaussie] Recursive function giving me "500 null" error
Hi guys, Trying to make a little helper tool for an online game that I play. The game has a very complex crafting system, and I'm trying to put together something to allow me to select an item I can craft and find out: a) all the things I need to make that item, all the way back to the raw materials, and b) all the things I can then make from that item. I've accomplished (b) no problem. Works beautifully. I can accomplish (a) back one step. Then I try to make that recursive to step all the way back to the beginning of the sequence and it throws a "500 null" error. So I did some reading and found out that this is an error that means something has gone wrong so fundamentally early in the code that it doesn't even know how to display the error. I found a suggestion of putting a just after the application setting, but that hasn't helped. Here are the two functions at play here. If someone can give me any suggestions about what I may have done wrong, I'd be very grateful. var result = arrayNew(1); var i = 1; var qItem = ""; qItem = getItemMadeBy(aItems[1].id); if (qItem.recordcount) { result[1] = structNew(); result[1].id = qItem.id; result[1].item = qItem.item; result[1].skill = qItem.skillname; result[1].makes = arguments.aItems; downTree(result); } SELECTi.id, i.item, s.skillname FROMdi_item i INNER JOIN di_itemItem ii ON i.id = ii.madeWithID INNER JOIN di_skill s ON i.skill = s.id WHEREii.itemID = I've removed the recursive call at the end of the first function so that you can see the thing in (sort of) action at http://frontandback.com.au/DarkIsles/index.cfm?do=main.craftTree - select an item such as "a wooden spool of thick thread" (the last item in the list). It will dump out all of the things that you can make from this item, and the things you can make from those items and so on.It will also show the item that the thread is made from. What I need is for it to go multiple steps back, however. Hope this all makes sense... Cheers, Seona. -- You received this message because you are subscribed to the Google Groups "cfaussie" group. To post to this group, send email to cfaus...@googlegroups.com. To unsubscribe from this group, send email to cfaussie+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en.