i need to make a program in qbasic that reads in an external file, which contains data sorted per line (just a simple text file). Then the program asks the user for a search query, and looks for hits in the file, and when a line is found that includes the user's query, it would then print the whole line. Any clues to this, should i read the file into a vector (1D-array)?
Comments
: i need to make a program in qbasic that reads in an external file, which contains data sorted per line (just a simple text file). Then the program asks the user for a search query, and looks for hits in the file, and when a line is found that includes the user's query, it would then print the whole line. Any clues to this, should i read the file into a vector (1D-array)?
:
Use [b]INPUT[/b] (not [b]INPUT$[/b] or [b]INPUT #[/b]) to get the user's query. Open the file using [b]OPEN ... FOR INPUT AS ...[/b]. Read the file a line at a time using [b]LINE INPUT #[/b]. Use [b]INSTR[/b] to check for the user's query. If it matches, use [b]PRINT[/b] to send it to the screen. With a little work, you could parse the line and show the user's query in a different color than the rest of the line.