a qustion about string length

Notices and updates
Locked
mostlywrong
Posts: 32
Joined: Fri Jan 09, 2009 10:54 pm

a qustion about string length

Post 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.

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post 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.
-- (define? (Cornflakes))

DrDave
Posts: 126
Joined: Wed May 21, 2008 2:47 pm

Re: a qustion about string length

Post 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.
...it is better to first strive for clarity and correctness and to make programs efficient only if really needed.
"Getting Started with Erlang" version 5.6.2

mostlywrong
Posts: 32
Joined: Fri Jan 09, 2009 10:54 pm

Post 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.

Locked