DataSection Improvements: Allow Vars Adrress Too

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Tristano
Enthusiast
Enthusiast
Posts: 190
Joined: Thu Nov 26, 2015 6:52 pm
Location: Italy
Contact:

DataSection Improvements: Allow Vars Adrress Too

Post by Tristano »

It would be nice if it was possible to put in DataSections also vars address, not just procedures and labels addresses:

Code: Select all

DataSection
  Data.i @SomeStr$
  Data.i @SomeVar
EndDataSection
So that those vars' pointers can be read and used to acces and manipulate them.

This would allow to build loops that manipulate vars via DatasSctions, reducing code size and redundancy.

Currently this can be achived via RunTime (which doesn't support structured variables!), but the above solution might be preferable.

Also, any chances that RunTime lib will support also structured vars in the future?
The PureBASIC Archives: FOSS Resources:
User avatar
helpy
Enthusiast
Enthusiast
Posts: 552
Joined: Sat Jun 28, 2003 12:01 am

Re: DataSection Improvements: Allow Vars Adrress Too

Post by helpy »

Code: Select all

DataSection
  Data.i @SomeStr$
EndDataSection
This will never work because the pointer to the string can change!
See following example:

Code: Select all

EnableExplicit

Define string1$
Define string2$

Debug Hex(@string1$) + " / " + Hex(@string2$)

string1$ = ""
string2$ = ""
Debug Hex(@string1$) + " / " + Hex(@string2$)


string1$ = "test1"
string2$ = "test2"
Debug Hex(@string1$) + " / " + Hex(@string2$)


string1$ = Space(1024)
string2$ = Space(1024)
Debug Hex(@string1$) + " / " + Hex(@string2$)
Windows 10 / Windows 7
PB Last Final / Last Beta Testing
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: DataSection Improvements: Allow Vars Adrress Too

Post by Josh »

helpy wrote:This will never work because the pointer to the string can change!
I think, it could work, because String$ itself is a pointer that never will change.
sorry for my bad english
Post Reply