Manipulating Stringarraypointer

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Michael Vogel
Addict
Addict
Posts: 2797
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Manipulating Stringarraypointer

Post by Michael Vogel »

I have written a resident starter program which should keep as less memory as possible - actually it uses around 5MB (inclusive virtual memory), some of it because of graphics and co.

But one part is also because I read the program names, descriptions, parameters, file pathes from datas - so it is kept two times in the memory.

At that moment I thought it could be useful to be able to set the pointer of string array members to a specific address manually but then one additional keyword would be needed to get the address of each entry of a data section

I think, I wrote everything a little bit too complicate, maybe I should do a pseudo code as well...
#Max=1000
Global Dim constants.s(#Max)
Global Dim a.s(#Max)
Global Dim b.s(#Max)

dummy.s
Restore
For i=1 To 6
; Set address of the string to the actual read pointer...
@constants(i)=#PB_Compiler_ReadAddress
Read Dummy;
Read a(i)
Read b(i)
Next

DataSection
Data.s "<<start 1>> very long text <<end>>","a","b"
Data.s "<<start 2>> very long text <<end>>","x","y"
Data.s "<<start :>> very long text <<end>>",":",":"
Data.s "<<start 1000>> very long text <<end>>","z","z"
EndDataSection
User avatar
Demivec
Addict
Addict
Posts: 4260
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Post by Demivec »

If I understand you correctly you are requesting a function that returns the current address where the next Read operation will read from.

If so, I think that would be useful also. If not this slight variation example would be shown below (at the risk of going OT).

Code: Select all

#Max=1000
Global Dim *constants.String(#Max)
Global Dim a.s(#Max)
Global Dim b.s(#Max)

dummy.s
Restore
For i=1 To 6
  ; Set address of the string to the actual read pointer...
  *constants(i) = PB_ReadAddress()
  Read dummy;
  Read a(i)
  Read b(i)
Next

DataSection
Data.s "<<start 1>> very long text <<end>>","a","b"
Data.s "<<start 2>> very long text <<end>>","x","y"
Data.s "<<start :>> very long text <<end>>",":",":"
Data.s "<<start 1000>> very long text <<end>>","z","z"
EndDataSection
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

Do a search, already requested:
http://www.purebasic.fr/english/viewtop ... light=read

Here is a solution I made:
http://www.purebasic.fr/english/viewtopic.php?t=30735

Here is a solution I made for the goto gosub stuff I also requested in the above link:
http://www.purebasic.fr/english/viewtopic.php?t=30736

It would be nice to have it as a native command though. :)
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
User avatar
Michael Vogel
Addict
Addict
Posts: 2797
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Post by Michael Vogel »

Thanks for your comments, you are right, this would be one of the things I'd like to have!

The second is to manipulate a string variable by changing the address to a special memory address. This would allow me to be able to use an array of string "constants" without additional memory...

Michael
Post Reply