I would love to see two utility additions that would streamline programming a bit.
First: an addition to SMCL that acts like the {opt} directive, but which infers the minimum abbreviation from capitalization rather than the position of a colon. That is, I might do the following in a help file:
Which looks like this when viewed:
keywords(string)
But it would be convenient to be able to code this as
This would be convenient because the -syntax- statement in the program already has the minimum abbreviation indicated that way, so it would save some time in creating help files...
Second: a subcommand parser, modelled on -syntax-, that handles the abbreviation of subcommands behind the scenes. Right now, programs that allow abbreviated subcommands begin with code like this (taken from graph.ado):
But wouldn't it be nice (and easier to debug) to be able to use my imagined -subcommandsyntax- command, which would return the unabbreviated subcommand in the local `subcommand'
First: an addition to SMCL that acts like the {opt} directive, but which infers the minimum abbreviation from capitalization rather than the position of a colon. That is, I might do the following in a help file:
Code:
{opt key:words(string)}
keywords(string)
But it would be convenient to be able to code this as
Code:
{nickopt KEYwords(string)}
Second: a subcommand parser, modelled on -syntax-, that handles the abbreviation of subcommands behind the scenes. Right now, programs that allow abbreviated subcommands begin with code like this (taken from graph.ado):
Code:
gettoken do 0 : 0, parse(" ,")
local ldo = length("`do'")
if "`do'" == bsubstr("display",1,max(2,`ldo')) { // draw/display
gr_draw_replay `0'
exit
}
if "`do'" == bsubstr("save",1,max(4,`ldo')) { // save
gr_save `0'
exit
}
if "`do'" == bsubstr("use",1,max(3,`ldo')) { // use
gr_use `0'
exit
}
if "`do'" == bsubstr("print",1,max(5,`ldo')) { // print
gr_print `0'
exit
}
if "`do'" == bsubstr("dir",1,max(3,`ldo')) { // dir
gr_dir `0'
exit
}
if "`do'" == bsubstr("describe",1,max(1,`ldo')) { // describe
gr_describe `0'
exit
}
Code:
gettoken do 0 : 0, parse(" ,")
subcommandsyntax 0 : DIsplay save use print dir Describe ...
gr_`subcommand' `0'

Comment