The new forums will be named Coin Return (based on the most recent
vote)! You can check on the status and timeline of the transition to the new forums
here.
The Guiding Principles and New Rules
document is now in effect.
Giant Programming Clusterfuck++
Posts
You could start by breaking it up and using includes. All of your static presentation material can be broken down, top to bottom, and then put into header / nav / footer pages and then linked in. If you want to go further, you could look into mvc, but it is hardly worth the bother on a one use site.
Yeah I don't know why I didn't make it clearer in my post, but I've already done that stuff. Even though all my pages are using common functions, I just can't shake the feeling that the calls of those functions shouldn't have to be duplicated. Also, if my structure is basically
There is no nice way to divide that into functions without making the structure of the page incredibly confusing, e.g. this coding of the above is awkward as hell because what if the structure changes (and the structure of this site is a good bit more complicated):
Basically if I roll the whole thing into functions, with calls nested based on the HTML tag nesting (which seems the most logical way to do it) then the structure of the page becomes dependent on really hard-to-follow relationships in my PHP code rather than a clear HTML presentation. But if I write more of the structure in HTML, then it becomes harder to maintain multiple pages in parallel. Gah, I will probably just find some balance like the above and substitute other functions for "retrieve_content" for different scripts that require it.
He has a prior version. The only way he had the bug he described is if the options were not being copied.
Uuuuuuuuuuuuuupdaaaaaaaaaaaaaaaaate!
You need some form of a Front Controller to do what you want. Basically, the values in your query string are commands that you want the script to execute. The content you want is based on those commands. Since most of your pages are the same, you can have one template page for those pages that displays different data based on the value of the query string command. You can see a simple/sloppy version of one with my code below:
controllertest.php (this is the code that actually uses the Front Controller):
controller.php (the actual Front Controller object):
request.php (helper object that gives us cleaner access to the $_REQUEST array):
commandfactory.php (an object that creates a command object based on the query string value):
Abstract base command class - command.php:
And an example login command - logincommand.php:
As you can see, this makes use of another object, the Receiver Factory. A receiver is that part of the system that should execute that command. In my example above, it's hard-coded to the command itself, which is probably not the best idea.
Admittedly, this code isn't great, but it should illustrate what I was talking about. The controller sits at the top of your application and filters the query string. It passes that result to the command factory, which retrieves the proper command (if it exists...if not a default/generic command is retrieved instead). The command itself is then executed. This execution method is where the 'magic' happens. In my example, I retrieved an object representing the login mechanism for an example site, then logged the user into the system. It shouldn't be a problem for you to run specific database queries for a specific page's content, then load a generic template page that can display those results.
The biggest hurdle are the pages that vary, but the biggest problem there is figuring out their display templates. The actual data processing will be placed within each command object. And, if most of those queries are the same, you can group them into functions, reducing code duplication even further.
I hope this made some kind of sense.
Note: the code above will only work with PHP 5+. Avoid PHP 4 like the plague.
My question would be: You are obviously using a C++ compiler, because you are using nested scope. In that case, why are you using character pointers at all? Step up to the plate and learn how to use std::string and save yourself the headache of worrying about this crap again. You'll have to store the std::string references you return the c_str() pointer from, but that's much easier than the headache of C string manipulation, which is antiquated and mostly worthless if you are working in an environment that has the C++ standard library.
IIRC, it is the number of nodes in the longest path. (leaf to leaf)
The maximum of the number of nodes for each level
or
2^(n-1) where n is the number of levels.
So this would be three or eight.
The width of a leaf node is 1. The width of a parent node is leftChildWidth + 1 + rightChildWidth. Do this recursively and the width of the root node will be how wide your tree is.
Like I said it's only use in calling it the width is in rendering the tree. If you know the width of children you can figure out where to lay out the nodes. If the root node width is 10, you need 10 columns, where do the left child and right child belong and where does the root node start?
Fear my quick mspaint skills!
The leaf nodes are obviously width 1, the non-leaf nodes have their width marked. Using those numbers you can determine where you would put each node when trying to render the tree top down without any collisions and no wasted space.
thanks
Since I couldn't quite figure out what Visual Studio data sources were about or how to customize them at all (and I think I couldn't get updating to work), I ended up programmatically populating my DataGridView with the relevant data using classes provided by the MySQL connector, such as MySqlDataAdapter and MySqlCommandBuilder. Then, to make searches work, I wrote algorithms to build SQL queries based on the GUI state. When a new query is built, I manually do a bunch of stuff to re-populate the DataSet using the MySql connector classes and the results of running the query.
This is ridiculously cumbersome of course (though on the plus side I will be able to make the database connection, schema, and expected table names / setups not hard-coded if I ever get around to it), so I've been working on a "DataGridViewManager" class to encapsulate all these issues with programmatically populating a DataGridView from MySQL. (Since I have multiple forms using the old methodology, rolling all the code up into one class will be a godsend.) Trouble is, I can't think of a good way to provide some kind of generic search interface.
What I want to know is, from anyone who has done this kind of programming before, are there facilities in .NET to automate data synchronization (between a DataGridView and a database) and query building that I'm not aware of? .NET is a monster and I don't own any good books on it, and Microsoft's examples are pretty basic sometimes (or over-numerous and hard to navigate to the most-relevant one).
I'll look into that (not that the wikipedia explanation of ODBC made any sense to my beer-addled mind the last time I tried to read it). I chose MySQL initially because web-server compatibility was important. (The data needs to be able to be easily mirrored on a web server that is.) But I think MySQL also has an ODBC connector, so if I can work with something Visual Studio can automate a little better it will be wonderful.
Edit: ODBC is a no-go. The connector seems hopelessly buggy, at least in Visual Studio. The IDE constantly crashes and doesn't show any tables. Oh well, the programmatic MySQL query thing has some advantages, especially now that I've finally got a lot of the bullshit encapsulated. I am still curious about ease of moving between Microsoft SQL server (lite or express or whatever) and MySQL though.
Another big concern is whether we're talking a balanced binary tree or not (assuming we're talking about printing, it is either way though). If you're printing a balanced binary tree, you can stick the head node in the middle, and then recursively print without worry with each child dedicated to 0-N/2-1 and N/2 - N-1.
If its an unbalanced binary tree
(etc) is more complicated. It can be done obviously but its more annoying (as I found when doing a personal project trying to create an ancestry chart, which can't be balanced without losing its meaning). If sufficiently large and unbalanced, you'll eventually either run out of space faster than the total amount of data would suggest or have to violate rules so a child leaf/node with stray to the wrong "side" of a grandparent node. The problem is that while balanced trees are intended to minimize the height of a tree, for printing each level of height in a tree implies greater width as well.
QEDMF xbl: PantsB G+
It's giving me an error:
"Failed to load and parse the manifest. The system cannot find the file specified."
I have no idea what step I skipped or what I typoed.
Help please!
The problem is not the code (though there are several syntax errors), the problem is how you are running it. What IDE are you using and how are you attempting to run it?
Sounds like you're using Visual Studio 2005 or later. It's not a typo in your code, but something going slightly wrong with your build settings.
If you go into your project properties (Alt+F7), then Configuration Properties -> Linker -> Manifest File, do you have:
Generate Manifest: Yes
Manifest File: $(IntDir)\$(TargetFileName).intermediate.manifest
Additional Manifest Dependencies:
?
I'm using Dev C++. I get the same thing in Visual C++ or Delphi 2007.
[EDIT] Ok! Now I get a console thing asking to enter a number(Saisissez un nombre) but whatever number I give it, I get 0 in return.
Oh ho! So I'm on Visual Studio 2008, and I went there(alt+F7) and I seem to have this:
Manifest File
Here's my code as of now:
I get a window(console?) that asks to enter a number(Saisissez un nombre) and gives back that number to itself(numberOne*numberOne). I need the exact opposite. For it to ask a number then give me back the square root(racine carrée). Also, does anyone know how to get weird characters(lol french) to show in the console? I get zeros where "é" should be.
I can get it to run if I have it start at the end and work backwards, but it screws up my results or my logic/method to get my results is flawed. I can't figure it out.
One of the options of this program is to capture a window that the user specifies with a mouse click. So the user clicks on a window, and then I get the top-most window where the click occurred using the WindowFromPoint function. My issue is that depending on where the click occurs in the window sometimes I won't get the handle of the window itself, I'll get a handle to a control or container that is a child of the window I'm actually wanting to get. If the click occurs on the title-bar of the window things go fine 99% of the time. So I know I'm having an issue with windows, child windows, and containers in some manner, but I can't exactly figure out what is going on and how I can solve the issue.
Example in spoiler (sorry bout the semi-large images):
If I click the title-bar, w00t, all is well. I get the full window:
But if I click in the area where each drive is listed in the detail view I get this:
I get the feeling I could try a while loop where I go up the chain calling GetParent until I get the desktop (hWnd = 0, I think) or a null handle and then use the last good value I got, but I dont know if that would work or if it'd be accurate. Does anyone have any ideas as to what I'm screwing up here or what I can do about it? Sorry if this is unclear, if anyone can help I can provide plenty more detail.
yea, that was the problem. However, now the issue is getting it to work properly.
What is supposed to happen is, given a range of coords, the object mutates based on how many neighbors it has for that generation and then shows that mutation in the next generation:
exactly 3, the cell gives birth to another organism
2 - 3, the organism survives to the next generation
>4 or <2 the organism dies
However, I can't seem to find a proper way to do this. Right now, I can check if the cell has any neighbors and tally a total, but I'm lost on how to make it do those statements. For example, if a cell is empty and has 3 neighbors, it'll give birth to a new organism. However, all the remaining cells see this and continue to use this new organism in their current calculations, when it shouldn't appear until the next generation. That's where I'm stuck at right now.
Edit: For clarity, I recommend using a few final static ints as constants to represent the states rather than continuing to use the numbers directly.
This. Typesafe enums are awesome.
1) Since you're using just C code you don't need those C++ headers (cstdlib and iostream).
2) You, um, don't ever actually calculate the square root anywhere. It's doing exactly what you're telling it to do: print the number and the number times itself.
3) As for the French characters, you may want to google this but you can try messing with the Regional and Language Settings in the control panel.
Read from original, write results to second array, replace original with second array.
I had the known points being printed off as well as their count. In the first generation, the neighbor method did not tally the count at all.
After the first generation, everything goes to 0 and all the points cease to exist.
If I comment out the death(index, index2); then everything stays where they are.
However, the birth method isn't doing what it's supposed to do either, which goes back to the neighbor method not properly checking anything at all.
What's supposed to happen is, each point has 8 neighbors. If that point has exactly 3 alive neighbors, that empty spot gives birth. If that point has more than 4 or less than 2, that point dies, and if that point has exactly 2 or 3, that point survives through till the next generation.
So my neighbor method starts at 1,1 and checks on that row for each column all 8 neighbors (index + or - 1) for left and right and (index2 + or -1) for up or down. At least I thought that's how I'm supposed to do it, but it doesn't seem to function at all.
Thanks for telling me about those C++ headers! I'm guessing I have to use math to get a square root right? Like, I can't write "numberOne = numberTwo*numberTwo;", so I need to get Two on the other side, with just One and something something on the other side? Arg, I'm not good at this. Is it "numberTwo = 1/numberOne;"? Nope, don't think so. Help?
That was exactly it. The count I was using was not the same count used in the other methods. The last thing I have an issue is, is with scanning for the key press enter. I'm not sure how I set up scanner or another method to check just for that keypress.
EDIT:
Disregard. I created a string to use the scanner; but then had that turn into an empty string.
I just needed it to pause and wait for the enter key to be pressed. Seems to work perfectly. Thanks everyone for all of your help.
Yes use the included math library in C to calculate out the square root. A okay reference is http://www.cplusplus.com/reference/clibrary/cmath/
Oh ho I got it! Here's the almost final code:
Well then, just call the method, why save the returned String if you don't need it?
And I never found it. In fact, it took me most of the afternoon just to get dbx to start up it's access-check and memleak functionality. Fuck me sideways, what a waste.
I wonder how feasible it would be to change the hundreds of raw pointers in this thing into boost::shared_ptrs and just be fucking done with it.
(edit) And the malloc() failure happens somewhere in the middle of a fstream::write call. Seriously, what the fuck.
(edit 2) And THEN you realize that one of those double-deletes you fixed wasn't a double delete at all and you've just caused a new leak! JOY! :x
(edit 3) AND WHY THE FUCK ISN'T lint INSTALLED ON THE DEV SERVER ROOOARHAHGHGHGHHGJHFDKJGHLK$EUYGL#gh
(edit the last) Oh yeah, the actual question. Besides lint (whenever I can get ahold of it :x) for static analysis and dbx's access-check for dynamic analysis, and finally stepping through the debugger piece by tiny sodding piece, are there any tools I'm forgetting for tracking down memory leaks, double deletes, etc that could be the cause of my malloc-in-the-middle-of-an-fstream-call error?