Page 1 of 1

PostPosted: Thu Feb 19, 2004 7:23 pm
by Doug
// The problem I am having is with the unpack() function.
// I can't get it to extract info to the data array
// Can someone point out the error in the following test code?
// TIA, Doug

//---------------- code below
//Unpack Test 1.0
@cid "UPAK";
@name "Upack";
@dbname "Upack";
@category "IR";
@ver "1.0";

string message="Upack 1.0\n";
// Signon message

#define SWITCH1 0
#define PACKETSIZE 2
#define BUFFSIZE 10

string csum1 = "90";
string csum2[3] = { "89\0" };
int sw1;

main() {
int data1[BUFFSIZE], data2[BUFFSIZE];
// # elements in the string

text(0,10, csum1 + " " + *csum2);
// Print test 'strings'

// unpack(data1, csum1, "1", PACKETSIZE);
// The previous statement should be the proper syntax
// but generates a Virtual Machine Error
// Addr:81,Func:main,Global ref out of range
// at run-time.

unpack(data1, &csum1, "2", PACKETSIZE);
// Should extract hex string to int
// does not error but computes incorrect result.
// Syntax does not seem correct.

sw1 = data1[SWITCH1];
text(0, 30, sw1);
// displays a '0'

// Following statement is a char array
// instead of string, results are the same
unpack(data2, csum2, "2", PACKETSIZE);
// Should extract hex string to int

sw1 = data2[SWITCH1];
text(0, 40, sw1);

while(!event(1));
}

PostPosted: Tue Feb 24, 2004 8:06 pm
by Doug
Reposted to:
Development Discussion\PocketC on Palm OS