Spurious character after KeyCharPrimitive

using KeyCharPrimitive in initialise, i have this output:

blahblah blah
[press any key]32 (or whatever code has the key pressed)
and blah, blah…

I simply can’t figure how to avoid this un-aesthetism… I guess that is often easily masked by an immediate use of ClearScreen, but there’s many cases where is better not deleting the lines above.

Suggestions ?

Best regards from Italy,
dott. Piergiorgio.

Did you put the KeyCharPrimitive() call in a print statement by accident?

mhm… I don’t get what you mean, but I have quickly cobbled together a little testing demo:

!% -~S
!% $OMIT_UNUSED_ROUTINES=1

! ----------------------------------------------------------------------------
!  Escape from cruelty
!    A non-interactive testing of an apparent issue with KeyCharPrimitive
! ----------------------------------------------------------------------------

Constant Story "Escape from cruelty";
Constant Headline "^A non-interactive testing^\
             Copyleft (L) 2021 by dott.Piergiorgio^";

Include "Parser";
Include "VerbLib";

Object hillside "Hillside slope"
  with description "You reached the safety at the base of that bare 
hillside."
  has  light;

[ Initialise;
  location = hillside;
	"^^Welcome to this little show...^
	[Press a key]",
	KeyCharPrimitive (),
	"You slow climb the slope of that bare hillside..^
	[Press space this time]",
	KeyCharPrimitive (),
	"I feel a foreboding presence, full of cruelness...^
	[Press return]",
	KeyCharPrimitive (),
	"Thunders and Lightnings..^
	[Now, why not prezz Z, as in Z for Zarf ?]",
	KeyCharPrimitive (),
	"In the blink of the lightning, you see the unmistakable figure of 
	Morgoth, the Cruel Flatulent Devil !^
	Thanks to that fleeting warning, you silently backtrack to the base of 
	that bare hillside, escaping with your life to a squashing demise!",
	deadflag =2,
	"^^FINIS.";

];

Include "Grammar";
end;

And this is the binary, compiled with the release 2 of Inform 6.35:
escruel.z5 (61.5 KB)

as you can see, the issue is indeed in the unaesthetic output, whose ruins this output.

Best regards from Italy,
dott. Piergiorgio.

You are indeed executing KeyCharPrimitive in the middle of a print statement, so yes, its return value will be printed. You are even setting deadflag within the print statement. A comma means there’s a new part of the print statement coming up. A semicolon means it’s the end of the statement.

I’m reasonably sure this is what you mean to do:

[ Initialise;
  	location = hillside;
	print "^^Welcome to this little show...^
	[Press a key]";
	KeyCharPrimitive ();
	print "You slow climb the slope of that bare hillside..^
	[Press space this time]";
	KeyCharPrimitive ();
	print "I feel a foreboding presence, full of cruelness...^
	[Press return]";
	KeyCharPrimitive ();
	print "Thunders and Lightnings..^
	[Now, why not prezz Z, as in Z for Zarf ?]";
	KeyCharPrimitive ();
	print "In the blink of the lightning, you see the unmistakable figure of 
	Morgoth, the Cruel Flatulent Devil !^
	Thanks to that fleeting warning, you silently backtrack to the base of 
	that bare hillside, escaping with your life to a squashing demise!";
	deadflag =2;
	"^^FINIS.";
];
2 Likes

So, in that case, I should not use the shortcut “” for print_ret “” ?
Got it, after all, in the actual case, is for separating in a consistent manner a long intro, and later in the work, the content of a letter (but let’s NOT, repeat NOT return on the examine/read diatribe…)

Thanks !
Dott. Piergiorgio.

ps. wow, now that I think on, it’s the very first time (in two decades !) that I actually released a complete, albeit non-iteractive, IF work…

The shortcut is not the problem. It’s that you need to do print rather than print_ret. Since you want to first print something, then call KeyCharPrimitive, then print something etc, you can’t do print_ret or the shortcut “bla bla” at the beginning - then you’ll just print the first string and return true.

You’ll note that the final string is printed with the “bla bla” shortcut for print_ret.

I’m thinking that maybe this shouldn’t be done in Initialise. GamePrologue would be better.

Having said that I think the instruction from
https://www.inform-fiction.org/inform63/whatsnew.html

is confusing Prologue/Epilogue.
Prologue is before ; Epilogue, after . isn’t it?

Well spotted. The descriptions of what GameEpilogue and GamePrologue do have been mixed up in this document. GamePrologue is in fact called before the main play loop and GameEpilogue is called after it.

1 Like

now I think that it’s time to talk seriously about the need of a DM4r…

Best regards from Italy,
dott. Piergiorgio.

1 Like

That web page is not from the DM4 and it’s not live documentation. It’s left over from 2005 and describes some pre-release work on the library.

My latest DM4 pdf copy is from 2001. Is there a link to a newer one?

Zarf, another misunderstanding…
Replying to Harry, the most recent DM4 pdf seems to me a release 4/2 of July 2001, describing inform 6.21 and library 6/9.
Now, replying (and clarifying again…) also to Zarf, seemed obvious to me that the substantial changes up to the current 6.35-library 6/12.5 put the, albeit excellent, DM4, in need of a major revision (for the record, DM3 described Inform 6.04-library 6/2 and the DM3 revised described Inform 6.13-library 6/5)

Hope to have explained my idea, and
Best regards from Italy,
dott. Piergiorgio.

The DM4 is is lively and cohesive work, and the kind of book for which the phrase “inimitable style” was invented. I would not dare try to update it as a text. That’s why I wrote up the Addendum document (describing compiler changes) as an addendum.

I’ll say what I’ve said before: If DavidG (or anyone) wants to start an Inform 6 Library Addendum document, I can post it at https://inform-fiction.org/.

albeit the IF community isn’t in the HMS Victory’s wardroom, is unquestionable that the DMs has an definite “Nelson touch”, so I must concur and agree with you.

let’s close the matter here.

Best regards from Italy,
dott. Piergiorgio.

I particularly enjoy the paperback version of DM4. I think the addendum is perfect for additions and corrections.