Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

A module to write a module

  • To: mathgroup at
  • Subject: [mg48543] A module to write a module
  • From: Goyder Dr HGD <h.g.d.goyder at>
  • Date: Fri, 4 Jun 2004 04:50:59 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

In an attempt to save a few seconds of typing I am trying to generate a
module that will provide a template for a new module. Thus by typing the


I will generate the following 

myName::usage = "myName...";
myName[] := Module[{},

Print["myName, at stage 1:"];

Print["myName, at stage 2:"];

Print["myName, at stage 3:"];

The above should be in an Input cell ready to be edited into the module I
need. It even has Print statements ready to tell me what it has managed to
do before inevitably going wrong.  Having saved a few seconds in typing I
might actually fill in the usage message. The above could even be
implemented by a button so that I don't even have to type ModuleTemplate. 

All I have managed so far is the following module.

ModuleTemplate::usage = "ModuleTemplate[yourName] 
- a fast way of getting started.";
ModuleTemplate[a_] := Module[{},
Cell[BoxData[MakeBoxes[ClearAll[#]; #::usage = "#[]...";
 #[] := Module[{}, Print["# Stage 1:"];]]], "Input"]] &[a];]

This is beginning to work but I can't get line breaks where I want them, the
usage message gets wrapped in quotes and the # in quotes does not translate
into the name in quotes. I feel that some subtle use of  MakeBoxes is
needed.  How do I fix this? Should I add any other features into my module

Many thanks for any help.

Hugh Goyder

This message has been scanned for viruses and
dangerous content by the Cranfield MailScanner, and is
believed to be clean.

  • Prev by Date: Re: Problem with transformation rules in Plot
  • Next by Date: Re: ext kalman filter
  • Previous by thread: Re: subtract a list of interpolating functions from another
  • Next by thread: Re: A module to write a module