Copyright 2001 (c) Logic Code Generator Ltd; You must not take information from this web page and reuse without the owner's permission!

LogicCoder Tutorial 6 of 7: GENERATE PROGRAM CODE

How to edit flowchart text and layout

This section of the tutorial introduces the basic operation of drawing a program flowchart with LogicCoder. You can use LogicCoder to quickly draw flowcharts by clicking symbols into position. You can also use LogicCoder layout editing features to align symbols relative to each other and to clip connecting line symbols to enhance the layout looks of your flowcharts.

Apart from easy program flowchart design, LogicCoder allows you to generate code using the control logic in your flowchart. This tutorial shows you how to draw the flowchart design for a relative simple program problem and then use the flowchart to generate a source program in BASIC and in ANSI C++.

At the end of going through these tutorials you should
Use LogicCoder GUI system to draw the flowchart for a relatively simple Input/Output program problem solution.
State the Advantages and Disadvantages of using Flowcharts to represent the Control Logic of a Computer Program

In this web page I show you the the following features of LogicCoder:

How to enter descriptive and language command statement text into flowchart symbols.

How to select multiple symbols and enter common text value in them.

How to Copy, Cut and Paste text content.

How to save and retrieve the whole text content of a flowchart.

How to use the same flowchart of a given control logic to generate code in different programming languages.

You get a free tutorial version of LogicCoder for ANSI C/C++ and BASIC programming whenever you make on-line purchase of any of the following books.

  • Structured Programming with BASIC I; ISBN 0-9544270-1-7; Price $44.00 USD
  • Structured Programming with ANSI C; ISBN 0-9544270-0-9; Price $56.00 USD
  • Object Oriented Programming with ANSI C++; ISBN 0-9544270-3-3; Price $66.50 USD

If you are doing this tutorial online, then you should have gone through the previous tutorial document before starting this section. IF YOU HAVE NOT DONE THE PREVIOUS SECTION.

Click the following link to download the tutorial in pdf format Download. You must observe all copyright in using the tutorial document. Here is a quick review of the program problem specification to begin with.

A program is to be designed and then coded in ANSI C/C++ that creates an output listing of telephone information on individuals. A sample of input data to be used for testing the program and the resulting output from the program is given as follows.

Name Telephone Number Area Code



Sample program test output



Use the mouse left button to click on the Select button on the flowchart template toolbar so that it appears sunken as illustrated in figure 11.



Switching off the draw mode

If you click in the user document window whenever the Select button is selected, LogicCoder will not draw a flowchart symbol. In this state, LogicCoder will highlight the symbol you click on. In this case, the symbol is selected. Any previously selected symbol is unselected.

You can also set the Select button to select a group of symbols by liaising with the mouse left button. In this case, you press and drag the mouse left button so that the set of symbols you want to select appears within the outlined rectangle that appear as you drag with the mouse left button. Figure 24 illustrates how this is done.

At this point, I will leave some of the illustration figures out as I do not want to have too much of a long web page. In addition as I proceed, I will also leave out additional information to restrict the size of this web page. However, you can have a full copy of the complete tutorial in pdf format by clicking the following link. Download

Select the Write Symbol Text menu item so that the function execute.

At this point, you should have a document window similar to that illustrated in figure 13.

The Write Symbol Text function allow you to place text in symbols by either writing the text value through the two text editing boxes or you can select an appropriate text value from a list associated with the selected symbol. Notice that the dialog window presented by this function also display the kind of selected symbol whenever it executes. This function allows you to place either a "Yes" or a "No" value in certain line symbols. The selected line symbol must be connected to a non Switch-Case decision symbol. In this case, if you select either of the two connected lines and then place a text value, the function will search for the other connected line symbol and then place the complementary text value in it.

LogicCoder also allow you to place text in other kinds of line symbols that form part of the entry in a select case structure. However, this tutorial version of LogicCoder does not allow you to implement flowcharts with the select case structure.

Click the button labeled START in the Terminal Text group of buttons so that it appear sunken as illustrated in figure 13 and then click the OK button.

At this point, LogicCoder places the text value "START" in the "Algorithmic" and the "Source Code" text views of the selected symbol.

Refer to figure 1 for a quick summary review of the description of the program algorithm to be implemented by our flowchart.

In the next few steps, you will place ANSI C/C++ source code command statements and descriptive text values in the sequence of symbols that follows.



Placing text in a terminal symbol


Use the mouse left button to select the first Input/Output symbol in the flowchart. That is, the Input/Output symbol that immediately follows the first Terminal symbol.

Recall that whenever we read the control logic given in a flowchart, we read from top to bottom and from left to right. Therefore, we do not use arrowhead flow-lines and we do not have left handed loops. This convention helps to simplify the analysis and evaluation of the control logic in a flowchart.

Use the shortcut button on the Edit function shortcut toolbar to execute the Write Symbol Text function.

At this point, your document window should look similar to that illustrated in figure 14

Click on the Algorithmic Text edit box so that it receive the focus and then enter the following descriptive text.
Print report Date line

The Algorithmic text editor allow you to enter text that describe the event or process that is to take place at that point in the program sequence represented by the flowchart symbol.









Placing text in the Input/output symbol

(1) Click on the Source Code text edit box so that it receives the input focus and then type in the following C/C++ source code.
printf("\n \n \t Current date: %20s", __DATE__)

(2) Click the OK button in the Write Symbol text dialog window when you are finish.

LogicCoder place the text you entered into the flowchart symbol. The descriptive text is display in the flowchart symbol as illustrated in figure 15.

The command statement is the actual instruction in a source language that tells the computer to do the thing that you describe with the Algorithmic text. You do not need to terminate a command statement with a statement terminator such as ";" in the case of C/C++ or similar languages.

STEP 13:
Select the HLine that follows the Decision symbol into the body of the loop and then execute the Write Symbol Text function.


Click the "No" button in the Write Symbol Text dialog window that appear and then press the Enter key or click the OK button.

Your document window should look similar to that in figure 17 before you click the OK button or press then Enter key.




Placing text in a decission line symbol

Notice that LogicCoder places the "Yes" text on the alternative line that follows the Decision symbol. LogicCoder search for a corresponding line that emanates from a Decision symbol and then place the complementary text in it whenever you choose to enter a "Yes" or a "No" text in a line symbol that connects from the Decision symbol. Both line symbols must flow from the Decision symbol. LogicCoder will not allow you to place any text in a line symbol that flows into a Decision symbol.

LogicCoder does not allow you to place such text in a line symbol that follows a Switch-Case Decision symbol. This is because the control logic implemented by a Switch-Case Decision is different from that implemented by a loop or a case decision.




Use the mouse left button to click the File menu item on the main menu bar so that the File pull-down sub-menu appears.

(1) Use the mouse left button to click the Save menu item in the File pull-down sub-menu so that the Save function executes.

(2) Save the file with the following name: Tutor00.flw. Make note of the location where this file is saved. You will look for the generated source code in this same location.

When you execute the Save function, LogicCoder saves both the flowchart and its text content together. However, you can also save the source code text separate from the flowchart and you can also load specific sequence of source code text into a flowchart.

If you save the source code text of a flowchart with the intention to reuse it at a future date, then you should pay careful attention to any changes that you do to the outlay of the control logic in the flowchart. Edit operations on a flowchart such as a symbol deletion affects the sequence of registered symbols in a flowchart. If the registered sequence does not match that in the saved source code, then the original source text will not load properly into the flowchart. More advance version of LogicCoder provides functions that help you to manage these kinds of situations.




In this section I show you how to create and insert data structures into a C++ program with use of the struct statement. I also show you how to create the required C/C++ source program from the flowchart.

Use the mouse left button to click the Settings item on the main menu bar so that the Settings pull-down sub-menu appear as illustrated in figure 18.



Click the Flowchart Settings menu item in the pull-down window so that the dialog window as that in figure 19 appears.






Setting flowchart attributes

Enter the following text in the text editor window labeled: Preprocess Directives
#include "stdio.h"
#include "string.h"
#define END "END OF FILE"

More advance versions of LogicCoder has functions that tells it to insert known include file headers in a generated C/C++ source program base on the use of command statements in the source code.

Enter the following text in the text editor window labeled: Declare Global Variable(s)
struct Tele {int Code; char Num[9]; char Name[12];};
struct Tele Telefile[ ] =

Click the Lock Symbols Positions check box so that it appears as illustrated in figure 19.

Click the OK button when you are finish step 6

Try dragging any symbol in the flowchart once the dialog window has disappeared from the document window. The flowchart symbols should not move whenever you attempt to drag them with the mouse.

In the next step you will execute the function that writes the required C/C++ source program.





Select the program language to write code in.

Click the Code item on the main menu bar so that the Code pull-down sub-menu appears as illustrated in figure 20.

Click the Write Program menu item so that LogicCoder generates the required C/C++ source code.


LogicCoder presents you with a series of message boxes that indicates where the program flowchart is stored on your system, diagnostic message that indicates connectivity of the flowchart and a message to indicate that the system is generating the required program. Make note of the location where the generated program is stored. When a source program is generated, it is stored in a text file with the name default to that of the flowchart file name except that the extension is that of the standard extension for the source language your system is set to.






Getting LogicCoder to write a program.

Use NotePad.exe to open the file that has the generated source program.


Your source code should look similar to that illustrated in figure 22.







Sample C/C++ program


(2) The top-down approach allow you to start with an abstract definition of a program problem, you identify specific components within the abstraction, repeat the process on these components until their description maps well onto statements within the domain in which the problem solution is to be implemented. The above explanation is an illustration of how you can do this with LogicCoder.

In the next section that follows, you will learn how to
Save the source code text view of a flowchart
Clear the source code text of a flowchart
Switch the source language of the flowchart
Enter command statements in the selected source language
Change symbol types in a flowchart
Set a select symbol to the ignore state when writing a source program
Generate a source program in the set source language





Click the Code item on the main menu bar so that the Code pull-down sub-menu appears as illustrated in figure 27.

The Code sub-menu consist of a set of functions that allow you to create source code files from a flowchart and to save and retrieve source code text view files for a given flowchart. You can also do chunk modification to a source code file by insertion of other code sequence such as data list or multiple comment lines.

LogicCoder provides five basic ways in which you can create a flowchart by interconnection of symbols.

  1. By using the mouse to select and then click symbols into their locations in the flowchart.
  2. By use of the free-mode option to attach flowchart symbols at selected points on other symbols
  3. By inserting control structures from templates.
  4. By editing a generic template structure so that the resulting control logic implement the required solution
  5. Edit an existing Control Logic in a flowchart

When you save a source code file, LogicCoder keeps track of the individual symbol to which each text string belongs. LogicCoder also store information that determines which source language the source code text file belongs to. LogicCoder do not allow you to load a source code text file into a flowchart that does not belong to the source language for which your system is currently set.





In this section, you will do changes to the flowchart layout so that it will generate a BASIC source program for the problem solution. In BASIC, you use the DATA statement to create a list of data values to be used by a program. As with C/C++, you can also create an array of data locations and then initializes the array with values. The pattern of initializing values must match the data structure pattern. However, a C/C++ compiler is more efficient at generating machine code for processing array of data values in terms of memory usage, convenience of implementation and time usage.

We have a different view of the way the system obtains its data values in the BASIC implementation of our program problem solution. This is because the data values used in the program are actually test data for the program. Actually, the final program is suppose to get its data values by reading data from an external device such as a magnetic storage medium.

Change the source language.
Select the Settings menu item on the main menu bar by clicking with the mouse left button or by highlighting and then press the Enter key. Then execute the Flowchart Settings function.

This is it for now folks! If you want to continue with the tutorial, then you should download the pdf file. You can also download a free tutorial version of LogicCoder for ANSI C/C++ and BASIC programming which you will need to actually do the activities in the tutorial. Let me do know if you have any problem by sending a message to

Go to the next sequenced page in this tutorial


Copy right May 2002
Logic Code Generator
142a Shenley Road
Tel: +44(0)79459609126
EMail: info@

You must not take information from this web page and reuse without the owner's permission!


Home | Contact us | Online Service | Links