I think I've found a fairly decent way of being able to embed data into a program at compile-time.
The data needs to be in C/C++, and needs to be REQUIRE'd (although using #include could work too).
You do need to have a slight bit of INLINE/ENDINLINE stuff to make the data available :
For example :
REQUIRE "defaultLanguage.c"
INLINE
}
extern char *defaultLanguage[];
namespace __GLBASIC__ {
ENDINLINE
And then just access the data in an INLINE function (but not in an extended type), eg :
FUNCTION Localise_TextHelper%:BYREF index%,BYREF token$,BYREF value$
token$=""
value$=""
INLINE
if (defaultLanguage[index])
{
token_Str=DGStr(defaultLanguage[(int) index]);
INC(index);
if (defaultLanguage[(int) index])
{
value_Str=DGStr(defaultLanguage[(int) index]);
INC(index);
}
return (DGNat) TRUE;
}
return (DGNat) FALSE;
ENDINLINE
ENDFUNCTION
I really love BlitzMax's Incbin command - much simpler to use than Shoebox and less faffing about.
Can you post a working example?
Yes will do soon-ish!
I've included a very simple example with getting a value from one integer array, but character arrays and structures could all be used, and with a bit of effort, MEM2SPR could be used to create sprites from the data.
[attachment deleted by admin]
incbin is sort of packing a binary file into your program?
Quoteincbin is sort of packing a binary file into your program?
Yes - it packs all media into your .EXE. Incbin=Include Binary.
I also asked about the possibility to have a function like it earlier, here; http://www.glbasic.com/forum/index.php?topic=3408.msg24964#msg24964
It's really easy to use in BlitzMax. You can check the link to see the syntax BM uses, Gernot.
How about something for OSX packing? So far it seems that an OSX distro will have its resources accessible since I haven't been able to get shoeboxes to work.
Shoebox should work on the Mac...
I would love to see a BlitzMax style incbin command on GLBasic. Is there are possibility it might get included ;) at some point?
I'll try to add it. It's pretty hard for all media and all platforms (with my current framework mess). I think about switching to SDL 1.3 for all platforms (static linking) and see what I can do with music playing.