Start a program by typing its name
A word the shell has no command for is now looked for on the disk as "<name>.sbx", and if it is there it is loaded and started exactly as load and run would do it. Whatever followed the word reaches the program through osArgument by the same route as whatever follows run, so "Say hello there" and "Type notes.txt" work without either program knowing how it was started. load and run are unchanged and both stay. load is how the monitor puts an arbitrary file in front of itself, which typing a name deliberately cannot do: the extension is added rather than assumed, so "notes.txt" looks for notes.txt.sbx and a text file is unreachable by name whatever is inside it. Three things this had to get right: The built-ins are tried first and always win. The search hangs off the end of the dispatch chain, so a file called dir.sbx cannot become dir, and the commands worth trusting when the disk is what you are doubting stay trustworthy. The invoke disk carries a working dir.sbx so that this is checked rather than asserted. A file that is found but is broken says so. "not a program" and "I do not know" are different answers, and giving the second about a file sitting on the disk would send somebody looking in the wrong place. loadProgram therefore hands back a status as well as a message, since only "no file of that name" can fairly be reported as anything other than a fault. doLoad became that subroutine rather than being copied. It ends in RET instead of a jump to the prompt, and each way of failing sets its number and its text together so a new one cannot leave half of the answer behind. cosmosBreak moves because Break prints the pointers it was handed and those are the shell's leftovers, which a CALL now puts back. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E2JrLzFvuFX9fgi1LDRjrW
This commit is contained in:
co-authored by
Claude Opus 5
parent
dbe58db660
commit
2b0aeeefd4
@@ -177,6 +177,25 @@ awk 'BEGIN { for (i = 0; i < 30; i++) printf "line %02d: ABCDEFGHIJKLMNOPQRSTUVW
|
||||
"$ROOT/Programs/CosmOS/Apps/More.asm" -o "$WORK/More.sbx" >/dev/null
|
||||
"$TOOL" put "$DISKS/type.img" "$WORK/More.sbx" >/dev/null
|
||||
|
||||
# A disk for invoking a program by typing its name. Four files, each there to say one
|
||||
# thing about how a typed word turns into a file name.
|
||||
#
|
||||
# dir.sbx is a working program under the name of a built-in command, which is the only way
|
||||
# to check that the built-ins really are tried first. If the search ever moved ahead of the
|
||||
# dispatch chain, this disk would start answering "dir" with a program.
|
||||
#
|
||||
# notes.sbx is text under a program's name, so that a file that IS found and IS NOT a
|
||||
# program can be told apart from a word that names nothing. notes.txt is the same text
|
||||
# under its own name, which no typed word can reach: "notes.txt" looks for notes.txt.sbx.
|
||||
"$TOOL" format "$DISKS/invoke.img" 64 2 >/dev/null
|
||||
"$ROOT/Assembler" -I "$ROOT/Programs/CosmOS/Source" \
|
||||
"$ROOT/Programs/CosmOS/Apps/Say.asm" -o "$WORK/Say.sbx" >/dev/null
|
||||
"$TOOL" put "$DISKS/invoke.img" "$WORK/Say.sbx" >/dev/null
|
||||
"$TOOL" put "$DISKS/invoke.img" "$WORK/Say.sbx" dir.sbx >/dev/null
|
||||
printf 'this is not a program' > notes.txt
|
||||
"$TOOL" put "$DISKS/invoke.img" notes.txt >/dev/null
|
||||
"$TOOL" put "$DISKS/invoke.img" notes.txt notes.sbx >/dev/null
|
||||
|
||||
# A disk for the assembler that runs on the machine. It holds a source file and the two
|
||||
# programs that check the front end - the reader on its own and the tokenizer on its own -
|
||||
# because a fault in either of those would otherwise turn up much later as a mysterious
|
||||
|
||||
Reference in New Issue
Block a user