Page 1 of 1

DataSection Improvements: Allow Vars Adrress Too

Posted: Sat Nov 25, 2017 6:38 pm
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?

Re: DataSection Improvements: Allow Vars Adrress Too

Posted: Sun Nov 26, 2017 9:14 am
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$)

Re: DataSection Improvements: Allow Vars Adrress Too

Posted: Sun Nov 26, 2017 11:41 am
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.