Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Is it possible to read user input from the console in Mata?


From   Aaron Kirkman <ak1795mailserv@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Is it possible to read user input from the console in Mata?
Date   Sun, 18 Nov 2012 07:51:25 -0600

Per a private email from Bjarte Aagnes
(Bjarte.Aagnes@kreftregisteret.no), the command I'm looking for is

****
display _request(macro name)
****

Per --help display--, this command takes input from the console and
places it in the **global** macro with the given name.

Aaron

On Sat, Nov 17, 2012 at 3:26 PM, Aaron Kirkman <ak1795mailserv@gmail.com> wrote:
> Dear Statalist,
>
> I'm hoping to write a Mata program that takes input from a user, but I
> haven't found a way to do this within Mata. -- search input, all --
> shows me several possibilities, but all of them involve switching back
> into Stata and taking input that way.
>
> 1. The --input-- command. This isn't exactly what I'm looking for,
> because I would like something simpler, like the --cin-- function of
> C++ or -- fgets -- in C. It seems like overkill to use --input-- when
> a user simply needs to enter one value in response to a prompt.
>
> 2. Dialog programming. Once again, this seems like a heavy solution
> for reading single values.
>
> Looking in  [M-4] io, I don't see any other options. Most of the
> functions listed here deal with either console output or file
> input/output, not console input.
>
> Are there any other options, besides the difficult (for me, at least)
> task of writing an input plugin in C? I realize Stata/Mata may not be
> designed for interactive programs like this, but I thought I would
> pursue it as a good way to learn Mata.
>
> Thank you,
> Aaron Kirkman
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index