Page 1 of 1

a qustion about string length

Posted: Fri Jan 09, 2009 11:15 pm
by mostlywrong
reading through the docs and forums i found that the max string length
is 2048 and needs to be enclosed inside [text] [/text] tags.

I'm thinking that i misunderstood something, because reading about
processing web pages I'm sure there are times that strings are longer
than 2048.

So what did i miss or misunderstand ?p.

Posted: Fri Jan 09, 2009 11:23 pm
by newdep
Hi,

the [text] [/text] quote you only need when you are creating texts
(>2048 chars) that should be i.e. printed to IO..

newlisp itself automaticly handles string size. If you processing a webpage
you dont have to bother about the size.

if you use i.e. get-url and would output it to the screen you
will see that newlisp automaticly marks it as [text]..[/text]..as
a referance that its 2048 long(er)...

Regards, Norman.

Re: a qustion about string length

Posted: Sat Jan 10, 2009 12:19 pm
by DrDave
mostlywrong wrote:reading through the docs and forums i found that the max string length
is 2048 and needs to be enclosed inside [text] [/text] tags.

I'm thinking that i misunderstood something, because reading about
processing web pages I'm sure there are times that strings are longer
than 2048.

So what did i miss or misunderstand ?p.
As with any new language, it takes a little time to figure out how to effectively search the docs.

From the manual:
Strings may contain null characters and can have different delimiters. They evaluate to themselves.

"hello" →"hello"
"\032\032\065\032" →" A "
"\x20\x20\x41\x20" →" A "
"\t\r\n" →"\t\r\n"
"\x09\x0d\x0a" →"\t\r\n"

;; null characters are legal in strings:
"\000\001\002" → "\000\001\002"
{this "is" a string} → "this "is" a string"

;; use [text] tags for text longer than 2048 bytes:
[text]this is a string, too[/text]
→ "this is a string, too"
You'll also get used to the parentheses. I often use a lot of extra lines to keep track of them:

Code: Select all

(setq result (div                        
                  (mul 100 
                       (add 
                            (div range 2)
                             val
                       )
                  )
                  range
              )
)
same as

Code: Select all

(setq result (div (mul 100 (add (div range 2) val)) range))
I find it much easier to scan through the code and see the arguments that are used with div, mul, add, div when it is not strung together in a single line.

Posted: Mon Jan 12, 2009 12:49 am
by mostlywrong
ok, i just misread the docs. what it said was text constants (more or less) in the code need to be tagged for the processor if larger than 2048 chars. got it.