mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: May 2005
Posts: 449
Fjord artisan
OP Offline
Fjord artisan
Joined: May 2005
Posts: 449
I'm trying to make a text file with questions and just the correct answer following it from a file with questions and four possible answers. Here's an example of one question and the answers.
Quote:

G1A01 (C) [97.301d]
What are the frequency privileges for a General Class control operator in the 160-meter band (ITU Region 2)?
A. 1800 - 1900-kHz
B. 1900 - 2000-kHz
C. 1800 - 2000-kHz
D. 1825 - 2000-kHz

The (C) in the first line means that C is the correct answer. I'd like to make a file that would take all of the questions like that and just have this in the file:
Quote:

What are the frequency privileges for a General Class control operator in the 160-meter band (ITU Region 2)?
C. 1800 - 2000-kHz


It's been way too long since I've done any scripting, and I can't figure this one out. I'd appreciate any help. Thanks.

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
This is rough, but it should be sufficient to give you an idea
Code:
var %question = $read(question.txt,2)
var %answer = $read(question.txt,$calc(3 + $asc($remove($gettok($read(question.txt,1),2,32),$chr(40),$chr(41))) - 65))


Presuming that the question is on line two, and that the coded answer (for lack of a better term) is on line one, then %answer will return the full line of the correct response.

I originally had %answer written out as about a dozen different lines, then combined them into one.

Joined: May 2005
Posts: 449
Fjord artisan
OP Offline
Fjord artisan
Joined: May 2005
Posts: 449
I still can't figure this out. My loops aren't right somehow. I've also changed this to write the output to a different file, not filter and overwrite the same file, since I think that would be better.

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
You gave a single example in your original post. Can you provide the first four or five entries like that? Having the extra entries will help me write you a better code.


Link Copied to Clipboard