Optional: install and run locally
ASPL 0.7.0 · Current release
Follow Get Started installation, then save, check and run the completed quiz locally.
On this page
What you will learn
This optional native lesson saves the completed one-file quiz, checks it and runs it locally with ASPL 0.7.0. Recognize the same input, output and process status while keeping the browser quiz available.
Before you begin
Complete or understand the browser quiz, and know how to open a terminal and change directories. Installation is not required for the browser course. You can skip this page and choose other next steps.
Follow the canonical installation
Use the Get Started downloads, system requirements and native installation and selection. Those pages own archive verification, installation, PATH selection and version checks. Select the published ASPL 0.7.0 executable before continuing. Console is optional; this lesson uses the terminal CLI. See check/run/build for command details.
Save the complete source
Export your completed Home quiz draft with Export source, or download one exact supplied variant below. Export saves your current edits as UTF-8 source; a supplied download is the catalog version. Save it as quiz.aspl in a new local directory and keep your original browser draft. No helper, data file or native library is needed for this one-file version. The English source uses English names and the .aspl extension; the Arabic source uses Arabic names and .لبات, with the same output strings. Save the Arabic version as اختبار.لبات and use that filename in the commands below. Documentation language never translates your exported file.
The complete source defines five Question records in a typed list, is_correct, summary and the root entry. It reads one line, checks exact q before parsing, retries parsing errors and counts each numeric answer once. Every new run initializes the counters; saving source does not save a score.
Execution: Native only · ASPL 0.7.0
- Optional local continuation. Select native ASPL 0.7.0 through Get Started. Save this one file as quiz.aspl; no modules or data files are required.
Input lines: ["5","5","12","4","15"]
record Question { prompt: string, answer: i64 }
fn is_correct(question: Question, answer: i64) -> bool {
return answer matches question::answer;
}
fn summary(label: string, correct: i64, answered: i64, total: i64) -> unit {
print(label + ". Correct: " + format_i64(correct) + "; answered: " + format_i64(answered) + "; total: " + format_i64(total) + ".\n");
}
fn start_main() -> i64 {
let questions: list<Question> = [
Question { prompt: "2 + 3?", answer: 5 },
Question { prompt: "9 - 4?", answer: 5 },
Question { prompt: "3 * 4?", answer: 12 },
Question { prompt: "12 / 3?", answer: 4 },
Question { prompt: "7 + 8?", answer: 15 }
];
let total: i64 = length(questions);
var index: i64 = 0;
var answered: i64 = 0;
var correct: i64 = 0;
print("Quiz: " + format_i64(total) + " questions. Type q to stop.\n");
while (index < total) {
let question: Question = questions[index];
print("Question " + format_i64(index + 1) + "/" + format_i64(total) + ": " + question::prompt + " ");
let line: string = read_line();
if (line matches "q") {
summary("Stopped early", correct, answered, total);
return 0;
}
let parsed: result<i64> = parse_i64(line);
if (parsed::ok) {
if (is_correct(question, parsed::value)) {
print("Correct.\n");
correct = correct + 1;
} else {
print("Wrong. Expected " + format_i64(question::answer) + ".\n");
}
answered = answered + 1;
index = index + 1;
} else {
print("Retry: " + parsed::error::code + ". Use ASCII digits, for example 5, or q.\n");
}
}
summary("Completed", correct, answered, total);
return 0;
}
Follow the Linux instructions to run this example. Download the source to keep a copy.
Download quiz-score-solution.asplExpected outcomes
{
"native": {
"check": 0,
"status": 0,
"output": "Quiz: 5 questions. Type q to stop.\nQuestion 1/5: 2 + 3? Correct.\nQuestion 2/5: 9 - 4? Correct.\nQuestion 3/5: 3 * 4? Correct.\nQuestion 4/5: 12 / 3? Correct.\nQuestion 5/5: 7 + 8? Correct.\nCompleted. Correct: 5; answered: 5; total: 5.\n"
}
}Check and run locally
Open a terminal in the directory containing quiz.aspl, or change to that directory first. Run these commands in order:
aspl check quiz.aspl
aspl run quiz.aspl
echo $?A successful check prints no quiz output and returns 0; it does not read input. Run prints the prompts and reads your terminal lines. Enter 5, 5, 12, 4, 15, each followed by Enter. Expect five Correct. lines and Completed. Correct: 5; answered: 5; total: 5. followed by a newline. The fifth answer finishes without another read. echo $? immediately after Run prints 0. It reports process status, not the printed score. Diagnostics use the CLI's selected language; output strings stay unchanged.
Predict the first prompt and final summary before running. A valid wrong number still advances; 12x retries; exact lowercase q ends early with status 0. EOF while waiting traps with input-exhausted and preserves prior output, without a guaranteed summary. Interrupting a local process with the terminal's Ctrl+C is a host interruption, not a normal quiz return; the browser's Stop action reports cancellation. Neither is quiz completion. The native input reference explains stdin and EOF.
Working directories and paths
quiz.aspl in the command is a native path relative to the terminal's current working directory. pwd shows that directory. Native text-file operations also resolve relative data paths from the process working directory; a source-module import resolves relative to its importing source file. An absolute native path names a local filesystem location.
Browser virtual filenames name flat temporary run data in one draft. They are not your Linux filesystem, exported source files or a source-module loader. Importing browser run files does not create local files; downloading a run file or exporting source saves a copy explicitly. The quiz itself uses stdin and stdout and needs no file data. See the text-file guide before adding native file operations.
Edit the banner and try an early stop
In a saved copy of quiz.aspl, change only the initial output string Quiz: to Local quiz: . Keep the trailing space, counters, helper and return values. Check the edited source, then run it. Predict Local quiz: 5 questions. Type q to stop. as the first line, with a newline. The banner edit changes printed text, not scoring or process status.
In this fresh local run, enter 5, 5, 0, then q. Predict two correct and three answered. Expect Wrong. Expected 12. after the third number and Stopped early. Correct: 2; answered: 3; total: 5. after q, with status 0.
Change the opening banner to Local quiz: in a copy of quiz.aspl, check it and run with 5, 5, 0, q. Explain why the edited text and printed score do not change the zero process status.
Hint: Edit the string in the initial print / اطبع call, keeping its final space. Run Check before Run. Trace correct and answered separately; q returns before counting the fourth question.
Show worked answer
The complete edited source below changes only the banner to Local quiz: 5 questions. Type q to stop. with a newline. The first two answers increment both counters. The third increments only answered and advances. q prints Stopped early. Correct: 2; answered: 3; total: 5. and returns 0. Neither the banner nor the score sets process status. Check prints nothing and returns 0; echo $? immediately after Run also prints 0. Start another run to reset all counters and keep the original browser quiz unchanged.
Execution: Native only · ASPL 0.7.0
- Optional local continuation. Select native ASPL 0.7.0 through Get Started. Save this one file as quiz.aspl; no modules or data files are required.
Input lines: ["5","5","12","4","15"]
record Question { prompt: string, answer: i64 }
fn is_correct(question: Question, answer: i64) -> bool {
return answer matches question::answer;
}
fn summary(label: string, correct: i64, answered: i64, total: i64) -> unit {
print(label + ". Correct: " + format_i64(correct) + "; answered: " + format_i64(answered) + "; total: " + format_i64(total) + ".\n");
}
fn start_main() -> i64 {
let questions: list<Question> = [
Question { prompt: "2 + 3?", answer: 5 },
Question { prompt: "9 - 4?", answer: 5 },
Question { prompt: "3 * 4?", answer: 12 },
Question { prompt: "12 / 3?", answer: 4 },
Question { prompt: "7 + 8?", answer: 15 }
];
let total: i64 = length(questions);
var index: i64 = 0;
var answered: i64 = 0;
var correct: i64 = 0;
print("Local quiz: " + format_i64(total) + " questions. Type q to stop.\n");
while (index < total) {
let question: Question = questions[index];
print("Question " + format_i64(index + 1) + "/" + format_i64(total) + ": " + question::prompt + " ");
let line: string = read_line();
if (line matches "q") {
summary("Stopped early", correct, answered, total);
return 0;
}
let parsed: result<i64> = parse_i64(line);
if (parsed::ok) {
if (is_correct(question, parsed::value)) {
print("Correct.\n");
correct = correct + 1;
} else {
print("Wrong. Expected " + format_i64(question::answer) + ".\n");
}
answered = answered + 1;
index = index + 1;
} else {
print("Retry: " + parsed::error::code + ". Use ASCII digits, for example 5, or q.\n");
}
}
summary("Completed", correct, answered, total);
return 0;
}
Follow the Linux instructions to run this example. Download the source to keep a copy.
Download quiz-native-solution.asplExpected outcomes
{
"native": {
"check": 0,
"status": 0,
"output": "Local quiz: 5 questions. Type q to stop.\nQuestion 1/5: 2 + 3? Correct.\nQuestion 2/5: 9 - 4? Correct.\nQuestion 3/5: 3 * 4? Correct.\nQuestion 4/5: 12 / 3? Correct.\nQuestion 5/5: 7 + 8? Correct.\nCompleted. Correct: 5; answered: 5; total: 5.\n"
}
}Check your understanding
Explain why Check prints no quiz prompts, why exporting source saves no score, and why a browser virtual filename is not a native path. No grade or progress is stored and navigation stays open. Continue optionally to source modules, or return to the one-file browser quiz.