QBasic file content search

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

  • [b][red]This message was edited by KDivad Leahcim at 2003-12-13 0:11:13[/red][/b][hr]
    : 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.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion