Mathematica Asked on March 26, 2021
Is there a way to Print
a message suitable for Message
? I want to recycle some messages (but Print
them, so they don’t get suppressed after X times and look like Print
output).
E.g.
Test::message="This is test number `1`.";
Message[Test::message,1]
Desired functionality:
PrintMessage[Test::message,1]
(* This is test number 1. *)
The inserting parts between back ticks is what really had me confused.
Just use StringForm
:
PrintMessage[mess_, val__] := Print@StringForm[mess, val]
Or StringTemplate
:
PrintMessage[mess_, val__] := Print@StringTemplate[mess][val]
Correct answer by xzczd on March 26, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP