Statalist


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

st: AW: problem with -return macro-


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: AW: problem with -return macro-
Date   Mon, 25 Jan 2010 19:14:36 +0100

<> 


" Why is -rlist- truncated to 244 chars in the return list?"




Well, it is not, the -ret list- is correct. You do, however, get bitten by
the "length of string in string expression" limit, which -display- obeys.
See -h limits-...

The code below shows that the -return list- contains the correct strings.
BTW, -test- is part of official Stata, so let`s call this thing "test2"...


*************
cap prog drop test2

program define test2, rclass
       version 11
       local rlist
       forv i=1/100 {
               local text "text`i'"
               local rlist `rlist' `text'
       }
       di "`rlist'"
       return local test `"`rlist'"'
end


log using mylog, name(newlog) replace

test2
ret li

log close newlog

//translate
translate mylog.smcl mylog.txt, replace
!start mylog.txt

*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Jeph Herrin
Gesendet: Montag, 25. Januar 2010 17:52
An: [email protected]
Betreff: st: problem with -return macro-


I thought I understood this, but maybe I'm just making
an obvious typo. When I run the following

************* test ***************
program define test, rclass
	version 11
	local rlist
	forv i=1/40 {
		local text "text`i'"
		local rlist `rlist' `text'
	}
	di "`rlist'"
	return local test `"`rlist'"'
end

test
di r(test)
**********************************

Why is -rlist- truncated to 244 chars in the return list? I have
tried this a number of different ways (I guess I have never tried
to return a long string before?); I thought as long as I used
macro copy rather than evaluate, macros would not get truncated.
I have tried many variations on the -return- assignment, but this
is the one explicitly recommended on [P] page 340.

thanks,
Jeph






*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/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/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