Page 1 of 1

PostPosted: Fri Nov 30, 2001 11:41 am
by Thad
HISCORELIB - A free open source code library for PocketC.

Makes keeping a high score table easy as pi:

http://thad.notagoth.org/palm/hiscorelib/

Yummy.

Thad

Thad

PostPosted: Mon Mar 21, 2005 9:18 pm
by ilvmegs
Personally, I can make pie easier; hopefully someone can lend me a little aid. I think I'm having a hard time with the pointers in the code.

I'm trying to create a small hiscore table demo using the hiscorelib. I doing good with creating the table and saving it. I've gotten the info back out of it but I can't figure out how to add a new score to the table. When I run the following applet I get the error: "Addr: 1484 Func: insert_HISCORE Global ref out of range".

Does anyone have some sample code of using this library? Or can you help me figure this out? Thank you!

Nick

ilvmegs

PostPosted: Mon Mar 21, 2005 9:19 pm
by ilvmegs
Oh, here's what I'm doing:

//high score demo

include "hiscorelib.h"

pointer p, hiscore, name;
int score;


main(){

clear();
new_HISCORE(10);
save_HISCORE(p, "testhiscore");

puts(getname_HISCORE(hiscore, 1) + ", " + getscore_HISCORE(hiscore, 1));

score = gets("score?");

wait();

insert_HISCORE(hiscore, score, name);

puts(getname_HISCORE(hiscore, 1) + ", " + getscore_HISCORE(hiscore, 1));
wait();

}//end main

ilvmegs

PostPosted: Tue Mar 22, 2005 4:10 am
by dewey
The biggest problem here is that you are calling new_HISCRORE, but not saving the result anywhere. You should be assigning this to "hiscore". When you call save_HISCORE, you should be passing "hiscore", not p (which is uninitialized, and is causing the crash).

PostPosted: Wed Mar 23, 2005 4:44 pm
by ilvmegs
The following gives me the table I expect. When I uncomment the insert_HISCORE() the program immediantly exits. How do I pass the Name and the Score to the insert_HISCORE so that it actually inserts the info into the db? If I uncomment the //name = *usname; I get a global ref out of range in the main funcion. I appreciate your help!

Nick

//high score demo

include "hiscorelib.h"

pointer p, hiscore, name;
int score;
string usname;

main(){

clear();
hiscore = new_HISCORE(5);
save_HISCORE(hiscore, "testhiscore");

usname = "Nick";
//name = *usname;
score = 10;

//insert_HISCORE(hiscore, score, name);

save_HISCORE(hiscore, "testhiscore");

puts(usname +score+"\n");
puts(getname_HISCORE(hiscore, 1) + ", " + getscore_HISCORE(hiscore, 1)+"\n");
puts(getname_HISCORE(hiscore, 2) + ", " + getscore_HISCORE(hiscore, 2)+"\n");
puts(getname_HISCORE(hiscore,3) + ", " + getscore_HISCORE(hiscore, 3)+"\n");
puts(getname_HISCORE(hiscore, 4) + ", " + getscore_HISCORE(hiscore, 4)+"\n");
puts(getname_HISCORE(hiscore, 5) + ", " + getscore_HISCORE(hiscore, 5)+"\n");

wait();

}//end main

ilvmegs

PostPosted: Thu Mar 24, 2005 2:53 am
by dewey
insert_HISCORE takes a pointer (hiscore), an int (score), and a string (usname). Since usname is not a pointer, you cannot dereference it, which is why "*usname" causes an error. "name" is a pointer, so you should not be passing it to insert_HISCORE (which expects a string). In fact, your code has no use for it at all. Get rid of "name" and "p".

Re: hiscorelib

PostPosted: Thu Oct 09, 2008 11:05 pm
by palmosm130
Hi... I've noticed that the hiscorelib is missing on all accounts. May I please get a copy? Thank You.