Page 1 of 1

PostPosted: Sat Mar 24, 2001 5:12 am
by Admin
In our programs, certain resource files are necessary. A game program usually has a few image files and sound files. If all of the files are packaged into one file, it will be easy to transfer. You can just beam the app file to a person next to you has PocketC runtime installed.

PocketC Compiler v3


<u>Package resource file</u>
Here is a special macro you can use to indicate which resource files the compiler needs to package.

<i>#resource ResoureID "Full File Path"</i>

ResourceID is an ID you give to your image or sound file.
"Full File Path" is the full path to this image or sound file located on your device or desktop.

Now the compiler will package these binary or text files into the finished app file.

<u>Load resource file</u>

Now when your app file is executed, the resource files will be unpacked into /temp directory. The file names will be dynamically generated base on the app file name to avoid duplicate image files.

In order to get the file path, just call


the function will return the dynamically unpacked file in the temp directory's file path. Just use these resource files in your program.


<pre id=code><font face=courier size=2 id=code>

#define ICO_SOKOBAN 1
#define BMP_BGROUND 2
#define BMP_BLANK 3
#define BMP_BOX 4
#define BMP_MAN 6
#define BMP_TARGET 7
#define BMP_WALL 8
#define DAT_SOKOBAN 9

#resource ICO_SOKOBAN "sokoban.ico"
#resource BMP_BGROUND "bground.bmp"
#resource BMP_BLANK "blank.bmp"
#resource BMP_BOX "box.bmp"
#resource BMP_MAN "man.bmp"
#resource BMP_TARGET "target.bmp"
#resource BMP_WALL "wall.bmp"
#resource DAT_SOKOBAN "sokoban.dat"

string filebmp;
filebmp = loadres(BMP_BGROUND);
drawimg( .... , filebmp);
</font id=code></pre id=code>

The solution helps us to package files into one final binary file.