Page 1 of 2

string bigger thant 64Ko

Posted: Fri Apr 25, 2003 5:19 pm
by golbi6666
Is there anyway to use string bigger than 64Ko ???
For using replacestring, findstring....
Thank you

Re: string bigger thant 64Ko

Posted: Sat Apr 26, 2003 9:02 am
by PB
> Is there anyway to use string bigger than 64Ko ???

Not until (hopefully) v4.00 of PureBasic.

Posted: Sat Apr 26, 2003 10:10 am
by GPI
Why do you need Strings bigger than 64Kb?

When you use Stings as buffer: Be carefull, my PRG has crashed under XP because of this (win98se doesn't crash).

Use the memory-library.

Strings >64k is more "up-to-date"

Posted: Sat Apr 26, 2003 2:58 pm
by newtheogott
To use MemAlloc etc. for large Amounts of data is maybe faster, but its not "true Basic".

And its not "as simple" to work with Replace, stringfilter etc.

I also prefer to use "Longstrings" and hope Fred will provide them one day ...

As said "Longstrings" are maybe slower, also the BASIC must do the "garbage-collection". However even "Data-Exchange" with VB may get more easy then.

And speed maybe important - but speed-of-developement is for many people (with todays computers) more important.

Posted: Sat Apr 26, 2003 8:23 pm
by Amiga5k
Which gives me an idea... Wouldn't it be cool if the string commands could also be used with memory banks, like CompareMemoryString()? Maybe with a 'Use Memory' switch? :)

There may come a day when I'll need a >64k string, but so far I've substituted memory banks with no problems (other than some extra coding required).

Russell

Posted: Sun Apr 27, 2003 6:52 am
by PB
> Why do you need Strings bigger than 64Kb?

Perhaps to read the contents of the clipboard?

> Use the memory-library.

But that's a lot of extra work, and as mentioned, isn't BASIC.
How would you do ReplaceString, FindString, Left, Mid, Right
and so on with memory blocks?

Garbage Collection ...

Posted: Sun Apr 27, 2003 7:58 am
by newtheogott
Thats all possible, but its unconvenient and its not BASIC.

The biggest difrence aboutall that is that the "BASIC-engine" has to do the "Garbage-Collection" which is been done "manually" if you use Memory-Blocks.

However, it should already be there, should maybe just need an enhancement to 4 Byte ... (2 Byte = 65536, 4 Byte = 2 Mrd. = actual Standard of most other Languages about strings).

Posted: Mon Apr 28, 2003 2:02 pm
by golbi6666
I would like to do string search/compare/replace on text files (30ko-2Mo)
I'll will waiting 4.0 ... And pray for big numbers too !
Thanks

Posted: Wed Apr 30, 2003 1:12 am
by Amiga5k
Does a string variable in PB hold the actual zero-terminated string or is it an address pointer TO the actual string data? I'm guessing that it's the first one, because otherwise I can't imagine why there would be a 64k limit (a long pointer can point to anywhere in memory, below 2Gb <4Gb if you have unsigned longs> :( ). I guess fixed-length strings could be stored at the address of the variable, but variable length/dynamic strings would be a pain to keep track of if their lengths could change (anything stored 'behind' it would have to be moved, etc).

Russell

Posted: Wed Apr 30, 2003 12:55 pm
by freak
A String Variable is a Pointer to the actual string.

PB uses a 64kb buffer for it's string operations, that's where the limit
comes from.

The problem is not storing the string, but working with it, this is limited.

Timo

If I understand it right we need "just" a new libr

Posted: Wed Apr 30, 2003 1:55 pm
by newtheogott
... with string-commands ?

That way the strings WOULD already be "longstrings" only the commands cannot handle them in "full length".

Posted: Wed Apr 30, 2003 2:07 pm
by freak

Code: Select all

a.s = "Hello "
a + "World"
This is also a String operation. So every string manipulation needs
this buffer.

Timo

I guess this system saves time while garbage collection ?

Posted: Wed Apr 30, 2003 2:23 pm
by newtheogott
I guess this system saves time while garbage collection ?

A fixed buffer which does not need pre-allocation ?

Therefore string-operations with the current system (and its limitations) should be faster then with other systems.

Otherwise I may ask myself why other languages like VB do not seem to use then a "non-fixed-size" temp-buffer.

However I would love to see that one day for PB too.
What you write makes hope that its not sooo much to change.

Posted: Wed Apr 30, 2003 4:52 pm
by GPI
Some Note:

Don't use Strings as Buffer.

I have done it.

Under Win98SE no problem, but under XP my program crash.

Posted: Thu May 01, 2003 5:39 am
by Amiga5k
How about a command 'SetStringBufferSize(size in bytes)' before any string commands are used to change the size of the internal buffer? I'm guessing that this would not be as easy as it sounds to implement...

Russell