This is tricky because the parser does some processing before the “reading a command” activity. It parses the command into words; if there are no words, it generates the “I beg your pardon” message and starts over without reaching the “reading a command” activity.
This is usually what one wants, but for your question it’s a nuisance.
You have to put your message in the “I beg your pardon” parser error. But this requires a bit of I6 code, because the “player’s command” snippet has spaces trimmed off.
Rule for printing a parser error when the latest parser error is the I beg your pardon error:
if the untrimmed command length is zero:
say "I beg your pardon.";
else:
say "You hit space."
To decide what number is the untrimmed command length: (- UntrimmedCommandLength() -).
Include (-
[ UntrimmedCommandLength;
#ifdef TARGET_ZCODE;
return (buffer->1);
#ifnot;
return (buffer-->0);
#endif;
];
-).
I7’s syntax is built in phrases, not tokens. You may find the I7 syntax reference helpful – see the stickied I7 docs thread (Inform 7 documentation and resources).