Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Reproducable system freeze on displaying certain output in Mata


From   "David Elliott" <[email protected]>
To   [email protected]
Subject   st: Reproducable system freeze on displaying certain output in Mata
Date   Wed, 13 Jun 2007 17:18:30 -0300

I'm having an issue with displaying output in Mata.  I am essentially
trying to use sprintf() to accumulate an output string in a string
scalar and then display it with a single display() or printf().  My
difficulty arises when there is more than one newline character "\n"
which sprintf() converts to "0a" in the accumulated string.

The following illustrates the problem using an interactive session
with the following commands and output:

mata
: result = 5.213

: sprintf("{txt}the result is {res}%f \n",result)
 {txt}the result is {res}5.213 0a

: line = sprintf("{txt}the result is {res}%f \n",result)

: line
 {txt}the result is {res}5.213 0a

: printf(line)
the result is 5.213

: display(line)
the result is 5.213

: line = line + sprintf("{txt}let's add another line \n")

: line
 {txt}the result is {res}5.213 0a{txt}let's add another line 0a

[warning! the next line may freeze Stata]
: printf(line)
the result is 5.213

screenful of blank lines ...

--more--

At this point the more condition cannot be cleared and neither a
keyboard ctrl+break nor a GUI break have any effect and the processor
utilization rises to 50% indicating some form of infinite loop
condition. The program cannot be terminated from the GUI and must be
shutdown using the Task Manager. Using -display(line)- causes the same
condition.

1) Am I misusing sprintf() printf() or display()?
2) Is it appropriate to build a long display string as I have attempted.
3) If not, can someone else duplicate this behaviour?
4) Is there a workaround?

System info:
Stata/SE 9.2 running on XP Pro SP2 with 316,685K memory alloted out of
1Gb system memory.

Thank you for any help.
--
David Elliott
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index