- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am planning to create a program that will use a big array of constant data when it executes. The obvious thing to do is read the data from a file, but I'm wondering if there is a way to read the data in during the compilation and store it with the executable code. Obviously this could be achieved by a DATA statement, but for a big multidimensional array it is a bit cumbersome. I'm pretty sure the answer is that there is no alternative to the DATA statement, but maybe there is something I don't know about.
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - gib
I am planning to create a program that will use a big array of constant data when it executes. The obvious thing to do is read the data from a file, but I'm wondering if there is a way to read the data in during the compilation and store it with the executable code. Obviously this could be achieved by a DATA statement, but for a big multidimensional array it is a bit cumbersome.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - tim18
Quoting - gib
I am planning to create a program that will use a big array of constant data when it executes. The obvious thing to do is read the data from a file, but I'm wondering if there is a way to read the data in during the compilation and store it with the executable code. Obviously this could be achieved by a DATA statement, but for a big multidimensional array it is a bit cumbersome.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - gib
It's generating the DATA statement that I was hoping to avoid. A vain hope, obviously, but it isn't a big deal anyway.
If you are only running on Windows then a user defined resource may suit. The data can be pulled from a file at (resource) compile time, which is then bound into the executable or DLL (as per other resources such as dialog templates or strings). At run time you then use Windows API functions such as FindResource and LoadResource, possibly in combination with the C_F_POINTER procedure from ISO_C_BINDING, to make the data available to the program.
I have used this approach to bind a default configuration file into an executable.
The online documentation for the resource compiler (rc.exe) has more information.
IanH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - IanH
If you are only running on Windows then a user defined resource may suit. The data can be pulled from a file at (resource) compile time, which is then bound into the executable or DLL (as per other resources such as dialog templates or strings). At run time you then use Windows API functions such as FindResource and LoadResource, possibly in combination with the C_F_POINTER procedure from ISO_C_BINDING, to make the data available to the program.
I have used this approach to bind a default configuration file into an executable.
The online documentation for the resource compiler (rc.exe) has more information.
IanH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You could potentially use Excel to generate the data satatments
1.2 3.4 5.6 ...
9.8 7.6 5.4 ...
.
.
.
Insertcolumns at left and at right
'DATA Array('1 ':' 10 ') /' 1.2 3.4 5.6 ... '/'
'DATA Array('+R-1C+10 ':' +R-1C+10 ') /' 1.2 3.4 5.6 ... '/'
Or write a program to convert the data to an includ file.
Use the Excel method for a once only situation
Use the program method should you want to create multiple tables or tweek the table later.
Jim Dempsey
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page