All Posts

Search Text File in Flowchart

Search Text File in Flowchart

In this tutorial, we will search for a text file using the Flowgorithm. This flowchart example will show the usage of the new File I/O flowchart symbols in action.

File I/O Symbols are:

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

The flowchart will prompt the user to enter a student name. It will search for the name in the file and let the user know if the student’s name is present in the input file.

Create a text file

The input text file to the flowchart contains the names of students. Create a text file called names.txt. Let’s assume that each student’s name is in a single line.

Sample file:

 

File Search Input File Flowgorithm

Design the flowchart

Let’s design the flowchart to search the text file.

Open the File

Open the input file in the Read mode using the Open file symbol.

Open input File Read Mode

Declare the variables.

String variables line and searchName. The line contains the student’s name in each line

Boolean variable isFound initially set to False. We will set this flag to True when there is a match.

Declare Variables File Search

Prompt the user to enter the search name. The user will enter that name to be searched in the file.

 

Add Loop and Read File

Add a loop and in the loop read the line using the Read file symbol. We will match it with the search name. If they both matches set the found flag to True and display that the name is in the file.

File Read File Search Command

Close the File

If not isFound then print the message that the name is not found. Close the file handle using the Close file symbol.

Close the File Search

Sample Output

Save and Run the flowchart with a test case. Search for a student name to view the output.

File Search Output Flowgorithm

—

Flowgorithm Tutorials

Flowgorithm flowchart tutorials on this website:

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