Statalist


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

Re: st: Maximum length of a string expression in a program


From   Maarten buis <maartenbuis@yahoo.co.uk>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Maximum length of a string expression in a program
Date   Mon, 16 Mar 2009 09:10:56 +0000 (GMT)

--- On Mon, 16/3/09, Davide Cantoni wrote:
> I have a question related to programming a new program/ado
> file. I am encountering the problem that one of the 
> arguments of my program might be too long as a string, 
> going beyond the limit of 244 characters. 
<snip>
> I am encountering problems when running -mycommand- with a
> list of regressors that is longer than 244 characters. 
> Then, the list is arbitrarily truncated after that limit.

You have to be a bit careful not to evaluate the local 
containing such a long string (i.e. avoid using the "=" when 
defining a local), but otherwise there should not be a 
problem with -gettoken- or the extended macro functions (I 
always type -help macro- and follow the link to the helpfile 
for the extended macro functions), even if the local surpasses 
the 244 tokens limit. This is illustrated in the example 
below:

*------------ begin example -------------------
forvalues i = 1/60 {
	local lstring "`lstring' very"
}
local lstring "`lstring' long string"

// the string has more than 244 characters:
di `: length local lstring'

// -gettoken- works:
gettoken first rest : lstring
di `:length local first'
di `:length local rest'
*------------- end example --------------------
(For more on how to use examples I sent to the Statalist, see
http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html )

Hope this helps,
Maarten

-----------------------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


      

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index