Fixing "undeclared identifier" for imgload, CaptureBmp, etc

Discuss PocketC for CE (including Desktop Edition)

Fixing "undeclared identifier" for imgload, CaptureBmp, etc

Postby ExpHP on Thu Feb 12, 2009 1:49 am

Here's how you can fix default.dat yourself to include the image-related functions that are in the help files but are unusable on CE PocketC.

This lets you fix: CaptureBmp, imgload, imgunload, imgtrans. Sorry, I haven't found out the id numbers yet for imgbitblt or imgstretchblt, but I will update with those numbers once I do.


Below is an introduction explaining various things you don't really need to know. On any other forum, I'd hide most of this in a spoiler-tag equivalent so that you don't have to scroll through what you don't want to read, but oh well.
If this is too tl;dr for you, just skip to the bright red text.

This issue plagued me for a long time. I searched the forums about it, but all I could find was a reference to a news link on the front page and links to something uploaded by a guy called Guy. The former has been bumped off the front page years ago, and Guy's page is now nonexistant (domains 4 sale BUY NAO!!!). The legendary "updated default.dat" is history. Well, I finally took a look at default.dat myself one day, and found that it's quite easy for us to fix the file ourselves!

Just to let you know, right now, Total Commander is all the rage, and so my post reflects that. But just to let this post withstand the sands of time, I'll explain what an equivalent program would need:
-Total Commander is a file explorer. Any file explorer that can copy and paste and make new folders will do.
-TC's built-in file editor can edit non-Unicode files anywhere of any type.
It's worth noting that the features added to the Open/Save dialogs and File Explorer by Spb Pocket Plus also suffice.

That out of the way, here we go:

Let me explain my best guess as to why these functions produce undeclared identifier errors. In the PocketC directory are two files used to compile: devicecompiler.dll (which I'll shorten to dc.dll) and default.dat.
In dc.dll are all the PocketC functions in binary form. However, the functions are not named, only numbered.
When you go to compile your program, the first thing the compiler does is read default.dat. This file has instructions for reading dc.dll; it tells the compiler to load all the numbered functions and to give these functions names.

The image functions are the newest additions before PCCE was abandoned. They were added to dc.dll, but the lines to load them in default.dat were not! This post will tell you how to add these lines to default.dat so they work as they should.

Are you ready?

WARNING: You will be editing a file integral to PocketC's development kit. Be sure to back up the file (step 2). I don't believe it is necessary to kill unclosed runtimes or even the editor (since this file is just used at compile time), though doing so is certainly a good habit to get into.

1) First, open TC. Navigate to the PocketC program directory. For me, it's \Program Files\PocketC.
2) Make a new directory in there for backup. Copy default.dat into the new folder.
3) Select default.dat (the original) and open TC's built-in text editor. Go down to the bottom. It should look like this:
Code: Select all
#export DEFAULT(262) regrbin(int,string,string,string&);
#export DEFAULT(263) regwbin(int,string,string,string);
#export DEFAULT(264) devicesipinfo();

Please be sure not to disturb those 4 empty lines at the end. I doubt they do anything, but I'd rather not find out the hard way. Put the typing cursor after that last semicolon and press Enter. Now here's where you begin typing:
4) I found these "DEFAULT" numbers by trial and error.
Code: Select all
#export DEFAULT(262) regrbin(int,string,string,string&);
#export DEFAULT(263) regwbin(int,string,string,string);
#export DEFAULT(264) devicesipinfo();
#export DEFAULT(266) CaptureBmp(int,int,int,int,string);
#export DEFAULT(267) imgload(string,int,int,int);
#export DEFAULT(268) imgunload(int);
#export DEFAULT(271) imgtrans(int,int,int,int,int,int);

Save the file. PocketC should now be able to use these functions without complaining about an "undeclared identifier."

I still don't know about the bitblts. Presumably, one is 269 and the other is 270, but when I try to use them I just get one pixel of color. :?

If copying what I wrote here does not work on your device, then there are version differences, and you need to find these numbers out through trial and error. Try putting different numbers in default.dat and running a simple test program until they work (if you have the wrong number, usually nothing will happen). Here's a good test for each:

CaptureBmp: Make sure the file you're telling it to save to does not exist. Run a simple program with the command, and open TC. Refresh. If the file appears, you have the right number.
imgload: Make a simple program with an imgload() inside a putsl(). Make sure the file/resource you're telling it to open exists. Run the program. If you have the right number, the Console should output random positive integers generally 6-8 digits long. The other functions tend to always return 0 or 1.
imgtrans: Once you get the test for imgload to work, load a colorful image with it and pass the handle to this function. If it displays, you have the right number.
imgunload: Once you get the test for imgtrans to work, add a line that unloads the image right after the line that loads it, but before the line that displays it. If you have the right number, the image will not show up.
And don't forget to always double all backspaces in a filename string (eg. "\\My Documents\\Prog\\")!

EDIT Feb 16 '08:
-Changed title to something more search-friendly (old title was "How to fix default.dat for imgload, imgtrans, CaptureBmp...")
EDIT March 3 '08:
-Attempted to make it more concise and brief, but ended up making it longer. Happens a lot.
Last edited by ExpHP on Sun Mar 15, 2009 7:19 pm, edited 3 times in total.
Posts: 1
Joined: Wed Feb 11, 2009 11:53 pm

Re: Fixing "undeclared identifier" for imgload, CaptureBmp, etc

Postby ArchiMark on Sun Feb 22, 2009 8:47 pm

Thanks for sharing this info, ExpHP!
Posts: 1
Joined: Sun Feb 22, 2009 8:41 pm

Return to PocketC for CE

Who is online

Users browsing this forum: No registered users and 1 guest