Alternative way of addressing elements of a structure?
Alternative way of addressing elements of a structure?
Is there an alternative way of addressing elements of a structure, such as indexing into it like with an array?
So rather than doing (pseudo code)
Structure WideDatabaseRecord
Column1.s
;...
Column200.s
EndStructure
NewList VirtualRecords.WideDatabaseRecord()
; select * from WideTable
VirtualRecord\Column1 = GetDatabaseString(1)
; ...
VirtualRecord\Column200 = GetDatabaseString(200)
I could loop though the structure elements assigning column values to them rather than having 200 lines of repetitive code....
So rather than doing (pseudo code)
Structure WideDatabaseRecord
Column1.s
;...
Column200.s
EndStructure
NewList VirtualRecords.WideDatabaseRecord()
; select * from WideTable
VirtualRecord\Column1 = GetDatabaseString(1)
; ...
VirtualRecord\Column200 = GetDatabaseString(200)
I could loop though the structure elements assigning column values to them rather than having 200 lines of repetitive code....
PB 5.73 on Windows 10 & OS X High Sierra
Re: Alternative way of addressing elements of a structure?
Array inside structure ?
Code: Select all
Structure WideDatabaseRecord
Array Column.s(200)
EndStructure
a.WideDatabaseRecord
a\Column(1) = "column 1"
a\Column(2) = "column 2"
Debug a\Column(2)
Windows (x64)
Raspberry Pi OS (Arm64)
Raspberry Pi OS (Arm64)
Re: Alternative way of addressing elements of a structure?
wilbert wrote:Array inside structure ?Code: Select all
Structure WideDatabaseRecord Array Column.s(200) EndStructure a.WideDatabaseRecord a\Column(1) = "column 1" a\Column(2) = "column 2" Debug a\Column(2)
That would only work if all database columns were of the same type....

PB 5.73 on Windows 10 & OS X High Sierra
Re: Alternative way of addressing elements of a structure?
Can you give a bit more information about how a record looks and what types you need to use for the columns ?kpeters58 wrote:That would only work if all database columns were of the same type....
Windows (x64)
Raspberry Pi OS (Arm64)
Raspberry Pi OS (Arm64)
Re: Alternative way of addressing elements of a structure?
would using an array of pointers work for you?
there is no sig, only zuul (and the following disclaimer)
WARNING: may be talking out of his hat
WARNING: may be talking out of his hat
-
- User
- Posts: 34
- Joined: Sun Nov 23, 2014 1:18 pm
Re: Alternative way of addressing elements of a structure?
How about using a SQLite-database in memory and accessing the data with SQL-commands? [OpenDatabase(#db_handle, ":memory:",..)]
Re: Alternative way of addressing elements of a structure?
I typically use SQLite's INTEGER & TEXT storage classes only (very rarely BLOBs as well).wilbert wrote:Can you give a bit more information about how a record looks and what types you need to use for the columns ?kpeters58 wrote:That would only work if all database columns were of the same type....
PB 5.73 on Windows 10 & OS X High Sierra
Re: Alternative way of addressing elements of a structure?
Hmm - interesting suggestion. Hadn't thought about that one yet...fabulouspaul wrote:How about using a SQLite-database in memory and accessing the data with SQL-commands? [OpenDatabase(#db_handle, ":memory:",..)]
PB 5.73 on Windows 10 & OS X High Sierra
Re: Alternative way of addressing elements of a structure?
Hmm - interesting suggestion. Hadn't thought about that one yet...fabulouspaul wrote:How about using a SQLite-database in memory and accessing the data with SQL-commands? [OpenDatabase(#db_handle, ":memory:",..)]
PB 5.73 on Windows 10 & OS X High Sierra
Re: Alternative way of addressing elements of a structure?
Hmm - interesting suggestion. Hadn't thought about that one yet...fabulouspaul wrote:How about using a SQLite-database in memory and accessing the data with SQL-commands? [OpenDatabase(#db_handle, ":memory:",..)]
PB 5.73 on Windows 10 & OS X High Sierra