English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Any ideas or code development help or something.

2007-12-10 15:34:11 · 2 answers · asked by quickanu 2 in Computers & Internet Programming & Design

2 answers

I'll assume you are somehow reading a program via text input to try to build this flow diagram.

I cannot claim to have done such a thing, but I have made a graphic representation of potential flow paths for a cross-referencer program.

To do the flow paths: Your key is to build lists of labels (transfer targets), goto/jump verbs (transfer actions), gosub/call verbs (transfer actions). Keep these in arrays of structures or something similar. You will need to know the line on which the label occurs, the line on which the goto/jump occurs, and whether the jump is conditional or invariant.

OK, you have a drawing field. You need to create a data structure representing a line you will draw. You visit each of the goto/jump statements to determine the size of the jump. For the shortest jump, allocate a line to connect the jump to its target. (You haven't drawn the line yet.) For every jump that does not contain another jump between itself and its target, allocate a line. If you find a case such as GOTO A and then label A: but another jump intervenes, skip that case.

At some point you have allocated lines for every jump to its label but where nothing would cross the lines. OK, mark those lines as level 1. Now scan again for lines. This time you might need to allow the lines to cross goto/jump statements. Again, draw the shortest lines first. These will be level 2. This repeats until you have allocated lines for every jump and have some number of levels.

What this gives you is the basis for now printing line numbers and connecting lines (on paper) to the logical lines you have allocated (in memory). Level 1 lines are the closest to your column of line numbers. Level 2 lines are next closest, and so on. On a line containing a GOTO/JUMP, you draw a horizontal sequence of dashes to the column you have allocated for the connector line. On a line containing a label that is a GOTO/JUMP target, you draw another horizontal sequence of dashes from that column to the label. On lines between the GOTO/JUMP and its target, remember to make a vertical bar or exclamation point in the chosen column.

To embellish this, my code used > and < on the horizontal lines ( --> on the GOTO/JUMP and <-- on the label line.) I also used an occasional ^ (caret) and v (lower-case v) as directional arrows in the vertical line to show whether the label was above or below the GOTO that selected it.

Hey, it was primitive - but it worked. This should give you an idea and overview of how to approach the problem. No, due to issues in code ownership, I cannot give you the code. I can discuss the algorithm in general, but that's all.

2007-12-10 15:51:36 · answer #1 · answered by The_Doc_Man 7 · 0 0

Sure you can use any language to write down. I used c++ and I'm sure you can find in the web code is c++ about flow charts. You are definitely going to use directed graphs or non-binary trees. It is a good job to do, but fun and interesting to write.
cheers !!!!

2007-12-10 16:04:01 · answer #2 · answered by kernel_1 2 · 0 0

fedest.com, questions and answers