Page 1 of 1

Manipulating Stringarraypointer

Posted: Mon Apr 14, 2008 7:11 am
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

Posted: Mon Apr 14, 2008 7:50 am
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

Posted: Mon Apr 14, 2008 8:48 am
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. :)

Posted: Tue Apr 15, 2008 10:02 am
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