Site icon TestingDocs.com

Read Text File using Flowgorithm

Overview

In this tutorial, we will learn to read text file using the Flowgorithm flowchart application. Flowgorithm 3.0 supports reading/writing text files.

The text file should be created or placed in the same directory. Flowgorithm will look for the file in the same folder as in the flowchart as the flowchart is located.

New Symbols

New flowchart file symbols that support the read/write operations on files.

https://www.testingdocs.com/flowgorithm-file-symbols/

Sample Flowchart

We will design a flowchart that reads the contents of the text file and echoes the file contents to the standard output console.

Let’s get started.

Launch Flowgorithm 3.0 application.

Create and Save the flowchart.

Create a text file in the same directory as the flowchart. For example, let’s create a sample ‘input.txt’ file and add some sample text content to the file.

Declare a String variable to hold each text line in the file.

Add a Open file symbol to the flowchart to open a file for reading the contents.

Specify the file name to read and the check the file Mode: Read

 

 

The file is opened in the Read mode. Add a loop to read each line.

Specify the loop exit condition as !EOF() ! is a NOT unary operator.

EOF()

EOF() is a file related function. It stands for End-Of-File. This function returns TRUE if the end of the file is reached. This function is used for reading an open file. So, to continue processing of an open file we have to check the condition that if !EOF() is TRUE.

Inside the loop, add a Read symbol.

The file read symbol reads the file and stores the value in the specified variable. In this case, each file text line is stored in the variable called ‘line’

Add an output symbol to display the content to the console window. Enter the variable line in the Output symbol.

After the loop add a file close symbol. It’s a best practice to close the files opened by the applications.

That’s it. We are done with the flowchart.

 

Flowchart Output

Run the flowchart to read and view the file contents on the output console window.

 

Flowgorithm Tutorials

Flowgorithm flowchart tutorials on this website:

https://www.testingdocs.com/flowgorithm-flowchart-tutorial/

For more updates please like our Facebook page:

Exit mobile version