Search found 16 matches

by ktamp
Sun Sep 23, 2007 9:40 pm
Forum: Feature Requests and Wishlists
Topic: Protected Structure types
Replies: 16
Views: 3984

Protected Structure types

One can already define a Structure type inside a procedure:

Procedure Test()
Structure Foo
l.l
b.b
EndStructure
Protected f.Foo
...
....
EndProcedure


Unfortunately Structure types are global to the program, so no other "Structure Foo" can be defined elsewhere in the program.

It would be ...
by ktamp
Thu Aug 23, 2007 7:34 pm
Forum: Coding Questions
Topic: Bug with pointer to String
Replies: 8
Views: 2285

That standard structure exists and is called String.

Not quite, as "MyStructure" contains a StructureUnion. On the other hand it finally downed on me how I could do the same thing using String and Long:

s.s = "abcd"
p.Long\l = @s
*s.String = @p

Changing p\l changes the position of *s\s.
by ktamp
Tue Aug 14, 2007 10:37 am
Forum: Coding Questions
Topic: Bug with pointer to String
Replies: 8
Views: 2285

Thank you. It took me almost a day after reading your first post to realize that "@string" returns the pointer value of "string" itself rather than a pointer to "string". I suppose PB should have a standard structure like your "MyString" to compensate for this fact.
by ktamp
Tue Aug 14, 2007 10:31 am
Forum: Feature Requests and Wishlists
Topic: StringField()
Replies: 11
Views: 3140

To Trond :
I said "pointer-to-pointer of string", like what CopyMemoryString() does.

To the.weavster :
Coming to PB from Python, at first I found myself uncomfortable with the lack of functions like Split() and Join(). Now that I have adjasted to the ways of PB, I can say I produce better code ...
by ktamp
Fri Aug 10, 2007 7:27 pm
Forum: Feature Requests and Wishlists
Topic: StringField()
Replies: 11
Views: 3140

Trond wrote:StringField() already works like that behind the scenes.
If that was true, my StringToken() would not be lightning faster than StringField() for parsing text files stored in a string buffer. What is killing StringField() is that it needs/uses that index argument...
by ktamp
Fri Aug 10, 2007 7:21 pm
Forum: Coding Questions
Topic: Bug with pointer to String
Replies: 8
Views: 2285

I pass a pointer-to-string to a procedure and I want to use standard string procedures on a part of that string without having to duplicate it.

Why isn't the expression valid? It should work since e.g. the following does:

n = 100
*p.Long = @n
PrintN(*p\l)

The tricky thing about strings is that ...
by ktamp
Wed Aug 08, 2007 6:46 pm
Forum: Coding Questions
Topic: Bug with pointer to String
Replies: 8
Views: 2285

Bug with pointer to String

Code: Select all

s.s = "abcd"
*p.String = @s
PrintN(*p\s)
causes "Invalid memory access". The following works correctly:

Code: Select all

Define s.String
s\s = "abcd"
*p.String = @s
PrintN(*p\s)
Tested with PureBasic 4.10b2 (Windows) and 4.01 (Linux).
by ktamp
Wed Aug 08, 2007 6:33 pm
Forum: Feature Requests and Wishlists
Topic: StringField()
Replies: 11
Views: 3140

StringField()

StringField() is not optimized for speed. PureBasic needs a fast pointer-to-pointer based function to extract fields from string, e.g. StringToken(@*PointerToString, Delimeter.s).

Another thing: Implementing my own version of such a function, I noticed that PureBasic lacks a Pointer structure ...
by ktamp
Mon Jul 23, 2007 10:38 pm
Forum: Feature Requests and Wishlists
Topic: Strings
Replies: 6
Views: 3656

Debug is off and the size of the string is 10^6 bytes.
by ktamp
Mon Jul 23, 2007 9:56 pm
Forum: Feature Requests and Wishlists
Topic: Strings
Replies: 6
Views: 3656

Then I wonder why on my system Len() is 18% slower than MemoryStringLength()...
by ktamp
Sun Jul 22, 2007 7:15 pm
Forum: Feature Requests and Wishlists
Topic: Strings
Replies: 6
Views: 3656

Strings

Strings are past as parameters to procedures by value, which is good but time consuming.

It would be better (faster) if a pointer to the original value was used internally as long as the procedure would not try to change this value, while this pointer would point to the new value if the procedure ...
by ktamp
Sat Jul 14, 2007 3:53 pm
Forum: Coding Questions
Topic: Problem with Dim
Replies: 9
Views: 1808

I know I'm getting annoying, but...

* While testing quad arrays, I found that Dim(Size) uses only the last 29 bits of Size. That is $01111111, $21111111, $41111111, $61111111, $81111111, $A1111111, $C1111111 and $E1111111 are all taken as $01111111... Cool bug!

* (edit) As expected, the last 30 ...
by ktamp
Thu Jul 12, 2007 11:37 pm
Forum: Coding Questions
Topic: Problem with Dim
Replies: 9
Views: 1808

In my previous test Dim would always allocate about 1.7GB (the free part of the 32bit-addressable 2GB memory). The inconsistent #MaxDim results made me rethink of my method.

This time, instead of a binary search model, I've tested memory allocation in incremental steps of 10^7 bytes. #MaxDim ...
by ktamp
Wed Jul 11, 2007 5:40 pm
Forum: Coding Questions
Topic: Problem with Dim
Replies: 9
Views: 1808

About 32bit systems allocating at most 2GB of memory, I've tested #MaxDim for all numeric types of PB. The allocated memory is always about 1.7GB. Anybody else noticing something weird here?

Type #MaxDim
.b 1850000000
.c 1850000000
.w 920000000
.l 1530000000
.f 1530000000
.q 1840000000
.d ...
by ktamp
Tue Jul 10, 2007 8:28 pm
Forum: Coding Questions
Topic: Problem with Dim
Replies: 9
Views: 1808

#MAXDIM=$7FFFFFFF
Apparently a signed long is used for array size, so $7FFFFFFF is the maximum value. But the first element of an array has index 0, so maximum index must be $7FFFFFFF - 1 = $7FFFFFFE.

Any notes about getting a non-zero pointer value using an index between 2G and 4G?