string bigger thant 64Ko

Everything else that doesn't fall into one of the other PB categories.
golbi6666
New User
New User
Posts: 2
Joined: Fri Apr 25, 2003 5:17 pm

string bigger thant 64Ko

Post by golbi6666 »

Is there anyway to use string bigger than 64Ko ???
For using replacestring, findstring....
Thank you
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: string bigger thant 64Ko

Post by PB »

> Is there anyway to use string bigger than 64Ko ???

Not until (hopefully) v4.00 of PureBasic.
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post 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.
User avatar
newtheogott
Enthusiast
Enthusiast
Posts: 120
Joined: Sat Apr 26, 2003 2:52 pm
Location: Germany, Karlsruhe
Contact:

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

Post 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.
--Theo Gottwald
-----------------------------------------
http://www.it-berater.org * http://www.fa2.de * http://www.smart-package.com
Amiga5k
Enthusiast
Enthusiast
Posts: 329
Joined: Fri Apr 25, 2003 8:57 pm

Post 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
*** Diapers and politicians need to be changed...for the same reason! ***
*** Make every vote equal: Abolish the Electoral College ***
*** www.au.org ***
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post 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?
User avatar
newtheogott
Enthusiast
Enthusiast
Posts: 120
Joined: Sat Apr 26, 2003 2:52 pm
Location: Germany, Karlsruhe
Contact:

Garbage Collection ...

Post 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).
--Theo Gottwald
-----------------------------------------
http://www.it-berater.org * http://www.fa2.de * http://www.smart-package.com
golbi6666
New User
New User
Posts: 2
Joined: Fri Apr 25, 2003 5:17 pm

Post 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
Amiga5k
Enthusiast
Enthusiast
Posts: 329
Joined: Fri Apr 25, 2003 8:57 pm

Post 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
*** Diapers and politicians need to be changed...for the same reason! ***
*** Make every vote equal: Abolish the Electoral College ***
*** www.au.org ***
freak
PureBasic Team
PureBasic Team
Posts: 5946
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post 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
quidquid Latine dictum sit altum videtur
User avatar
newtheogott
Enthusiast
Enthusiast
Posts: 120
Joined: Sat Apr 26, 2003 2:52 pm
Location: Germany, Karlsruhe
Contact:

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

Post by newtheogott »

... with string-commands ?

That way the strings WOULD already be "longstrings" only the commands cannot handle them in "full length".
--Theo Gottwald
-----------------------------------------
http://www.it-berater.org * http://www.fa2.de * http://www.smart-package.com
freak
PureBasic Team
PureBasic Team
Posts: 5946
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

Code: Select all

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

Timo
quidquid Latine dictum sit altum videtur
User avatar
newtheogott
Enthusiast
Enthusiast
Posts: 120
Joined: Sat Apr 26, 2003 2:52 pm
Location: Germany, Karlsruhe
Contact:

I guess this system saves time while garbage collection ?

Post 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.
--Theo Gottwald
-----------------------------------------
http://www.it-berater.org * http://www.fa2.de * http://www.smart-package.com
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

Some Note:

Don't use Strings as Buffer.

I have done it.

Under Win98SE no problem, but under XP my program crash.
Amiga5k
Enthusiast
Enthusiast
Posts: 329
Joined: Fri Apr 25, 2003 8:57 pm

Post 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
*** Diapers and politicians need to be changed...for the same reason! ***
*** Make every vote equal: Abolish the Electoral College ***
*** www.au.org ***
Post Reply