New topic: 

Dinamically update a string inside a structure

<http://forums.realsoftware.com/viewtopic.php?t=30537>

       Page 1 of 1
   [ 3 posts ]                 Previous topic | Next topic         Author  
Message       ziopulcher           Post subject: Dinamically update a string 
inside a structurePosted: Sun Oct 18, 2009 2:15 am                        
Joined: Tue Sep 08, 2009 10:00 am
Posts: 8              Sirs,
I have a problem that seems very silly.Is it possible to dinamically update teh 
dimension of a structure inside a structure.
For what I see it seems nope, but in this case it's amazingly bad! Maybe I am 
wrong somewhere
I have  a structure like this

Mystructure
MyArray(-1) as string

And pushing on a button I want to do

dim a as mystructure
dim b as string

b="ziopulcher"
a.myarray.append "b"   
                            Top                Phil M           Post subject: 
Re: Dinamically update a string inside a structurePosted: Sun Oct 18, 2009 2:30 
am                        
Joined: Fri Sep 30, 2005 12:18 pm
Posts: 140              No not possible inside a structure (at least for now).  
All structures use a fixed size as you define it.  

You have 2 options (if they work for you)... make the string field large enough 
to hold the biggest string you think your data could need, then the rest of the 
string will be zero padded, and you can extract it like a CString.

Second is to make the string field a Pointer within the Structure, and assign 
the value as the pointer to a MemoryBlock.  See pointers and MemoryBlocks for 
more details about that.   
                            Top               jefftullin           Post 
subject: Re: Dinamically update a string inside a structurePosted: Sun Oct 18, 
2009 3:10 am                        
Joined: Wed Nov 15, 2006 3:50 pm
Posts: 843              You should use a class if you want to dynamically 
change the contents in this way.
That was true in VB also.
A structure is great if (and really only if) you expect the memory footprint to 
be constant.
A class allows you to add initialisation code and access methods   
                            Top           Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 3 posts ]     
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to