TransWikia.com

Print a Message

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]

enter image description here

Desired functionality:

PrintMessage[Test::message,1]
(* This is test number 1. *)

The inserting parts between back ticks is what really had me confused.

One Answer

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

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP