Creating Named Structured Arrays during Runtime

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
purely
New User
New User
Posts: 9
Joined: Thu Sep 27, 2007 11:23 am
Location: Israel

Creating Named Structured Arrays during Runtime

Post by purely »

Say, you create a form designer for a DB

Now you want the "custom" fields on the form (in fact the DB) to be represented by real a Structured Array name, not something like creating 20 preconfigured arrays (Field 1, Field 2) with referenced names.

IS THIS POSSIBLE ? (at least, in PB)

Purely.
byo
Enthusiast
Enthusiast
Posts: 635
Joined: Mon Apr 02, 2007 1:43 am
Location: Brazil

Post by byo »

Can't you use structures for that?
User avatar
Demivec
Addict
Addict
Posts: 4260
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Post by Demivec »

purely wrote:Now you want the "custom" fields on the form (in fact the DB) to be represented by real a Structured Array name, not something like creating 20 preconfigured arrays (Field 1, Field 2) with referenced names.
Do you mean that you want a structure that has fields and names like a database object, or other runtime creation? If so, then you would use any suitable runtime data type for it. I would use an Array1(#of records) of pointers to blocks of memory that were the individual records of whatever size and type. To access their contents you would have to keep track of the fields within the structure through the use of another Array2(#of fields) which would record record offsets and types, and possibly the field's name.

I am sure other options are viable.

If you meant instead about creating an interpreter type construct where the program modifies itself to refer to the parts of a form by changing it's sourcecode, I think you heading down the wrong path. If need be, you could have a program write source code and cause it to be compiled and then executed (at least according to my theories). Since PB is not interpreted, a runtime custom procedure would be best. IMHO
purely
New User
New User
Posts: 9
Joined: Thu Sep 27, 2007 11:23 am
Location: Israel

Post by purely »

Demivec wrote:
purely wrote:Now you want the "custom" fields on the form (in fact the DB) to be represented by real a Structured Array name, not something like creating 20 preconfigured arrays (Field 1, Field 2) with referenced names.
Do you mean that you want a structure that has fields and names like a database object, or other runtime creation? If so, then you would use any suitable runtime data type for it. I would use an Array1(#of records) of pointers to blocks of memory that were the individual records of whatever size and type. To access their contents you would have to keep track of the fields within the structure through the use of another Array2(#of fields) which would record record offsets and types, and possibly the field's name.

I am sure other options are viable.

If you meant instead about creating an interpreter type construct where the program modifies itself to refer to the parts of a form by changing it's sourcecode, I think you heading down the wrong path. If need be, you could have a program write source code and cause it to be compiled and then executed (at least according to my theories). Since PB is not interpreted, a runtime custom procedure would be best. IMHO
I thought about the last option, it's too complex.

The first option sounds good...

I am not used to using pointers in this way, will do some experiments next days...

Thanks so far.
Post Reply