ASPL لباتASPL 0.7.0

Search documentation

Search starts with current English documentation · ASPL 0.7.0

Enter a complete name such as read_line, or words about a topic.

    العربية
    Source files

    Open one UTF-8 .aspl or .لبات file, up to 1 MiB, in a new draft. It stays in this browser and does not run automatically.

    Text input

    ASPL 0.7.0 · Current release

    Read a name unchanged and distinguish an empty line, waiting, EOF and cancellation.

    On this page

    What you will learn

    Print a prompt, read a name without changing its text, and predict an empty reply. Identify waiting for input, exhausted input and cancellation as separate outcomes.

    Before you begin

    Read first output for printing and functions for calls and returned values. This independent program supplies its own entry. Open it as a new Home draft, then choose Run. Earlier drafts stay available.

    Ask for a name

    print / اطبع writes the prompt Name: , including its final space. It adds no newline. read_line() / اقرأ_سطر() takes no arguments and returns string / نص. It prints no prompt itself. The call waits until you submit a line, then removes the line terminator while preserving the other characters. let name binds that returned text to an immutable name.

    Browser and native · ASPL 0.7.0 · English source

    Execution: Browser and native · ASPL 0.7.0

    Prerequisites:
    • Read the example explanation in its lesson before running.

    Input lines: ["سلمى"]

    fn start_main() -> i64 {
        print("Name: ");
        let name: string = read_line();
        print("Hello, " + name + "!\n");
        return 0;
    }
    
    Download lesson-input.aspl

    Expected outcomes
    {
      "browser": {
        "check": "success",
        "class": "success",
        "output": "Name: Hello, سلمى!\n",
        "processStatus": 0
      },
      "native": {
        "check": 0,
        "status": 0,
        "output": "Name: Hello, سلمى!\n"
      }
    }

    The string operator + joins "Hello, ", name and "!\n" in that order. The explicit \n ends the greeting line. Submit سلمى and program output is exactly Name: Hello, سلمى!\n. The input echo is separate from program output. The reserved start_main() -> i64 / ابدأ_الرئيسية() -> ص64 entry ends with return 0 / أرجع 0, a normal process status rather than printed text.

    Type the reply in the running program's input field, not the source editor. It needs no quotes. A name containing spaces or Arabic text keeps those characters. Runtime input is not source notation. The source editor's digit conversion outside strings and comments does not convert runtime input. Changing the reading language or supplied source vocabulary does not translate the prompt, your reply, or an existing draft.

    Predict an empty reply

    Run the program and choose Send line with an empty field. What text does name hold? It is the empty string "", so output is exactly Name: Hello, !\n, with normal status 0. An empty submitted line is still a line; it is different from closing input. Submitting سلمى instead produces Name: Hello, سلمى !\n. No trimming occurs.

    Waiting, Close input and Stop

    Use a fresh explicit Run for each demonstration.

    1. Leave the input field untouched. The prompt remains visible and execution waits at read_line. It has not completed and has no process status yet. Submit a line to continue.
    2. Run again, type unsent in the field, then choose Close input without Send line. Close input supplies EOF and does not send those unsent characters. The waiting read traps with input-exhausted. Output remains exactly Name: . There is no greeting or normal entry return. A read after exhausted input is an uncatchable trap, not a recoverable result or an empty string.
    3. Run again and choose Stop while waiting. Execution is cancelled, with the prompt still visible. Cancellation is separate from EOF and normal completion; it does not return status 0.

    The browser labels the trap and cancellation in the execution outcome, separately from output. See browser input for the controls and line input for the full contract.

    Change the greeting

    Change only Hello, to Welcome, . Submit سلمى. Expected output is exactly Name: Welcome, سلمى!\n, with normal status 0; an empty reply produces Name: Welcome, !\n.

    Change the greeting to Welcome, while preserving the name exactly. Predict the empty-line output too.

    Hint: Change the first string in the greeting expression. Keep the prompt, read_line call, name and final newline.

    Show worked answer

    Only the greeting prefix changes. read_line still returns the submitted name unchanged, and + joins it between the new prefix and the suffix. With سلمى the output is Name: Welcome, سلمى! followed by a newline. With an empty line the name contributes no characters, leaving Name: Welcome, ! and a newline. Both submitted-line runs return status 0.

    Browser and native · ASPL 0.7.0 · English source

    Execution: Browser and native · ASPL 0.7.0

    Prerequisites:
    • Read the example explanation in its lesson before running.

    Input lines: ["سلمى"]

    fn start_main() -> i64 {
        print("Name: ");
        let name: string = read_line();
        print("Welcome, " + name + "!\n");
        return 0;
    }
    
    Download lesson-input-solution.aspl

    Expected outcomes
    {
      "browser": {
        "check": "success",
        "class": "success",
        "output": "Name: Welcome, سلمى!\n",
        "processStatus": 0
      },
      "native": {
        "check": 0,
        "status": 0,
        "output": "Name: Welcome, سلمى!\n"
      }
    }

    Check your understanding

    Explain which call prints the prompt, what the read removes, and why an empty submitted line succeeds while EOF traps. Compare waiting, Close input and Stop in separate runs. No grade or progress is stored, and navigation stays open. Return to the Tutorial path.

    Browse pages