Subj : Re: Flowchart software that supports top down development? To : comp.programming From : Richard Heathfield Date : Fri Jul 29 2005 07:56 pm Roman Mashak wrote: > Hello, Richard! > You wrote on Wed, 27 Jul 2005 08:12:19 +0000 (UTC): > > RH> No, but I can think of an easy way to do it yourself. > Does this technique suppose to prepate this sort of file manually? That wasn't my intent (although Phlip has already indicated that it could easily be done that way). Rather, I was presuming that the code to generate the file would be included in the program itself. Let me give you an example in the mythical language "CODEX" (which is a brand new programming language of my own invention, primarily characterised by the fact that you make up the syntax as you go along, which makes it impossible to implement but quite handy for language-blind Usenet discussions!): PROC LogLabel PARMS String name, Flag stub ENDPARMS IF genflow ECHO genflow, " " ECHO genflow, name ECHO genflow, " [label=\"" ECHO genflow, name ECHO genflow, "\" fontcolor=\"white\" color=\"" IF stub ECHO genflow, "red" ELSE ECHO genflow, "blue" FI ECHO genflow, "\" style=\"filled\"];\n" FI ENDPROC PROC LogCall PARMS String caller, String callee ENDPARMS IF genflow ECHO genflow, " " ECHO genflow, caller ECHO genflow, " -> " ECHO genflow, callee ECHO genflow, ";\n" FI ENDPROC # foo is a stub PROC foo PARMS String this, String that ENDPARMS LogLabel PROCNAME, TRUE ENDPROC # bar is implemented PROC bar PARMS String this, String that ENDPARMS LogLabel PROCNAME, FALSE LogCall PROCNAME, "foo" foo this, that LogCall PROCNAME, "baz" baz this, that ENDPROC # baz is a stub PROC baz PARMS String this, String that ENDPARMS LogLabel PROCNAME, TRUE ENDPROC FUNCTION main PARMS StringList args ENDPARMS IF StringList[0] EQCI "-genfuncchart" THEN genflow = OPEN "flowchart.dot" ECHO genflow, "digraph \"G\" {\n" LogLabel "main", FALSE ELSE genflow = 0 FI LogCall PROCNAME, "foo" # PROCNAME applies to functions too :-) foo stuff, otherstuff LogCall PROCNAME, "bar" bar whatever, thingy ECHO genflow, "};\n" CLOSE genflow RETURN 0 ENDFUNCTION In the above pseudocode, the logging code dominates because there's hardly any implementation code. In practice, the overhead per function is very low (look, for example, at the bodies of foo and baz, where a single line of code is sufficient to document the stub). Just by running the program (with the -genfuncchart option), you generate the dot file. (In fact, I note from the above that my original dot file attempt was a little out in terms of the order you'd get, but the principle is sound, I think.) -- Richard Heathfield "Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.uk mail: rjh at above domain .