Need some newbie help please
- SimonLothar
- Senior Member
-
- Posts: 605
- Joined: Sat Sep 15, 2012 6:59 am
- Location: Krautland ****
- Calculators: Casio fx-7400GII, Casio fx-7400GII (SH4), Casio fx-9750GII, Casio fx-9750GII (SH4), Casio fx-9860G, Casio fx-9860G SD, Casio fx-9860G Slim, Casio fx-9860GII SD, Casio fx-9860GII SD Power Graphic 2, Casio Classpad 330 plus, Casio fx-CG20, Casio fx-CG50, Casio Classpad fx-CP400
Re: Need some newbie help please
This is the version for the storage memory.
Keep in mind that if Bfile_CreateFile fails, most probably the customer has to perform an optimization. I'll post the main memory version later. But as I do not like the SDK's main memory functions at all, we'll have to extend your syscall library.
Keep in mind that if Bfile_CreateFile fails, most probably the customer has to perform an optimization. I'll post the main memory version later. But as I do not like the SDK's main memory functions at all, we'll have to extend your syscall library.
- Code: Select all
// size of a set's identification
#define IDSIZE 8
// count of doubles per item in set1
#define SET1COUNT 5
// count of doubles per item in set2
#define SET2COUNT 4
// count of items in SET1
#define SET1LEN 8
// count of items in SET2
#define SET2LEN 100
//
typedef struct {
unsigned char id[IDSIZE+1];
double value[SET1COUNT];
} TSet1;
//
typedef struct {
unsigned char id[IDSIZE+1];
double value[SET2COUNT];
} TSet2;
const FONTCHARACTER filename[] = { '\\', '\\', 'f', 'l', 's', '0', '\\', 'T', 'E', 'S', 'T', '.', 'B', 'I', 'N', 0 };
//
int AddIn_main(int isAppli, unsigned short OptionNum)
{
unsigned char out_buffer[20];
unsigned int key;
int i, j, failed, handle, size;
TSet1 Set1[ SET1LEN ];
TSet2 Set2[ SET2LEN ];
// initialize the arrays, just to have something to work on
// the variables will have the names "SET1_0".."SET1_7"
memset( Set1, 0, sizeof Set1 );
for ( i = 0; i < SET1LEN; i++ ){
sprintf( (char*)Set1[ i ].id, "SET1_%d", i );
for ( j = 0; j < SET1COUNT; j++ ){
Set1[ i ].value[ j ] = 0.125 + i * 10.0 + j;
}
};
// the variables will have the names "SET2_0".."SET2_99"
memset( Set2, 0, sizeof Set2 );
for ( i = 0; i < SET2LEN; i++ ){
sprintf( (char*)Set2[ i ].id, "SET2_%d", i );
for ( j = 0; j < SET2COUNT; j++ ){
Set2[ i ].value[ j ] = 0.333 + i * 10.0 + j;
}
};
// first delete the file
Bfile_DeleteFile( filename );
// now save the arrays to the storage memory
size = sizeof Set1 + sizeof Set2;
failed = Bfile_CreateFile( filename, size );
locate( 1, 4 );
sprintf( (char*)out_buffer, "%d", failed );
PrintLine( out_buffer, 21 );
GetKey( &key );
if ( !failed ){
handle = Bfile_OpenFile( filename, _OPENMODE_READWRITE );
if ( handle >= 0 ){
Bfile_WriteFile( handle, Set1, sizeof Set1 );
Bfile_WriteFile( handle, Set2, sizeof Set2 );
Bfile_CloseFile( handle );
}
};
// now destroy the arrays again for verification
memset( Set1, 0, sizeof Set1 );
memset( Set2, 0, sizeof Set2 );
// reload the arrays from storage memory
handle = Bfile_OpenFile( filename, _OPENMODE_READ );
if ( handle >= 0 ){
Bfile_ReadFile( handle, Set1, sizeof Set1, -1 );
Bfile_ReadFile( handle, Set2, sizeof Set2, -1 );
Bfile_CloseFile( handle );
};
// verify: f. i. find SET1_3 and display its third value
for ( i = 0; i < SET1LEN; i++ ){
if ( strcmp( (char*)Set1[i].id, "SET1_3" ) == 0 ){
locate( 1, 4 );
sprintf( (char*)out_buffer, "%f", Set1[i].value[2] );
// should be 32.125
PrintLine( out_buffer, 21 );
GetKey( &key );
}
}
// verify: f. i. find SET2_33 and display its second value
for ( i = 0; i < SET2LEN; i++ ){
if ( strcmp( (char*)Set2[i].id, "SET2_33" ) == 0 ){
locate( 1, 4 );
sprintf( (char*)out_buffer, "%f", Set2[i].value[1] );
// should be 331.333
PrintLine( out_buffer, 21 );
GetKey( &key );
}
}
.
.
.
I'll be back!
- MrMagoo
- Member
-
- Posts: 44
- Joined: Tue Jul 02, 2013 11:57 am
- Location: London
- Calculators: Casio fx-7400G, Casio fx-7400G PLUS, Casio fx-7400GII, Casio fx-9750G, Casio fx-9750G PLUS, Casio fx-9860GII
Re: Need some newbie help please
If I have a double, 123.456 for example.
How do I seperate the 123 from the .456?
I tried floor, but that didnt work.
I couldnt find a round function.
I also tried sprintf( (char*)printline1, "%i", wcb ) & sprintf( (char*)printline1, "%0.3f", wcb );
How do I seperate the 123 from the .456?
I tried floor, but that didnt work.
I couldnt find a round function.
I also tried sprintf( (char*)printline1, "%i", wcb ) & sprintf( (char*)printline1, "%0.3f", wcb );
"The trouble with internet quotations, is that the majority are totally made up." - Abraham Lincoln 1863
- SimonLothar
- Senior Member
-
- Posts: 605
- Joined: Sat Sep 15, 2012 6:59 am
- Location: Krautland ****
- Calculators: Casio fx-7400GII, Casio fx-7400GII (SH4), Casio fx-9750GII, Casio fx-9750GII (SH4), Casio fx-9860G, Casio fx-9860G SD, Casio fx-9860G Slim, Casio fx-9860GII SD, Casio fx-9860GII SD Power Graphic 2, Casio Classpad 330 plus, Casio fx-CG20, Casio fx-CG50, Casio Classpad fx-CP400
Re: Need some newbie help please
Refer to "SHC Manual.PDF", page 318. And #include <math.h>.
I'll be back!
- MrMagoo
- Member
-
- Posts: 44
- Joined: Tue Jul 02, 2013 11:57 am
- Location: London
- Calculators: Casio fx-7400G, Casio fx-7400G PLUS, Casio fx-7400GII, Casio fx-9750G, Casio fx-9750G PLUS, Casio fx-9860GII
Re: Need some newbie help please
SimonLothar wrote:Refer to "SHC Manual.PDF", page 318. And #include <math.h>.
tried that, but it just returns 0
"The trouble with internet quotations, is that the majority are totally made up." - Abraham Lincoln 1863
- MrMagoo
- Member
-
- Posts: 44
- Joined: Tue Jul 02, 2013 11:57 am
- Location: London
- Calculators: Casio fx-7400G, Casio fx-7400G PLUS, Casio fx-7400GII, Casio fx-9750G, Casio fx-9750G PLUS, Casio fx-9860GII
Re: Need some newbie help please
I have created my own bitmaps to use a menu system within a result screen, and copied the code to the bitmaps.hpp file.
I have then inlcuded this before the while loop
But get this error
C:\Users\d\Desktop\Projects\Inputs\Bitmaps.hpp(245) : C5040 (E) Expected an identifier
I think its telling me, that the item is undefined, but I thought that by listing it in bitmaps.hpp will define it? Or is it something else?
I have then inlcuded this before the while loop
- Code: Select all
DISPGRAPH dg;
dg.x = 50;
dg.y = 01;
dg.GraphData.width = 48;
dg.GraphData.height = 41;
dg.GraphData.pBitmap = (unsigned char*)01MENU01;
dg.WriteModify = IMB_WRITEMODIFY_NORMAL;
Bdisp_WriteGraph_VRAM( &dg );
But get this error
C:\Users\d\Desktop\Projects\Inputs\Bitmaps.hpp(245) : C5040 (E) Expected an identifier
I think its telling me, that the item is undefined, but I thought that by listing it in bitmaps.hpp will define it? Or is it something else?
"The trouble with internet quotations, is that the majority are totally made up." - Abraham Lincoln 1863
- SimonLothar
- Senior Member
-
- Posts: 605
- Joined: Sat Sep 15, 2012 6:59 am
- Location: Krautland ****
- Calculators: Casio fx-7400GII, Casio fx-7400GII (SH4), Casio fx-9750GII, Casio fx-9750GII (SH4), Casio fx-9860G, Casio fx-9860G SD, Casio fx-9860G Slim, Casio fx-9860GII SD, Casio fx-9860GII SD Power Graphic 2, Casio Classpad 330 plus, Casio fx-CG20, Casio fx-CG50, Casio Classpad fx-CP400
Re: Need some newbie help please
MrMagoo wrote: dg.GraphData.pBitmap = (unsigned char*)01MENU01;
01MENU01 is not allowed as variable name. It mustn't start with a digit.
I'll be back!
- SimonLothar
- Senior Member
-
- Posts: 605
- Joined: Sat Sep 15, 2012 6:59 am
- Location: Krautland ****
- Calculators: Casio fx-7400GII, Casio fx-7400GII (SH4), Casio fx-9750GII, Casio fx-9750GII (SH4), Casio fx-9860G, Casio fx-9860G SD, Casio fx-9860G Slim, Casio fx-9860GII SD, Casio fx-9860GII SD Power Graphic 2, Casio Classpad 330 plus, Casio fx-CG20, Casio fx-CG50, Casio Classpad fx-CP400
Re: Need some newbie help please
MrMagoo wrote:tried that, but it just returns 0SimonLothar wrote:Refer to "SHC Manual.PDF", page 318. And #include <math.h>.
This works for me and gives "123.000000":
- Code: Select all
#include "math.h"
.
.
.
unsigned char out_buffer[20];
unsigned int key;
double d;
d = floor( 123.456 );
locate( 1, 4 );
sprintf( (char*)out_buffer, "%f", d ); // should be 123.000...
PrintLine( out_buffer, 21 );
GetKey( &key );
I'll be back!
- MrMagoo
- Member
-
- Posts: 44
- Joined: Tue Jul 02, 2013 11:57 am
- Location: London
- Calculators: Casio fx-7400G, Casio fx-7400G PLUS, Casio fx-7400GII, Casio fx-9750G, Casio fx-9750G PLUS, Casio fx-9860GII
Re: Need some newbie help please
SimonLothar wrote:This is the version for the storage memory.
Keep in mind that if Bfile_CreateFile fails, most probably the customer has to perform an optimization. I'll post the main memory version later. But as I do not like the SDK's main memory functions at all, we'll have to extend your syscall library.
- Code: Select all
// size of a set's identification
#define IDSIZE 8
// count of doubles per item in set1
#define SET1COUNT 5
// count of doubles per item in set2
#define SET2COUNT 4
// count of items in SET1
#define SET1LEN 8
// count of items in SET2
#define SET2LEN 100
//
typedef struct {
unsigned char id[IDSIZE+1];
double value[SET1COUNT];
} TSet1;
//
typedef struct {
unsigned char id[IDSIZE+1];
double value[SET2COUNT];
} TSet2;
const FONTCHARACTER filename[] = { '\\', '\\', 'f', 'l', 's', '0', '\\', 'T', 'E', 'S', 'T', '.', 'B', 'I', 'N', 0 };
//
int AddIn_main(int isAppli, unsigned short OptionNum)
{
unsigned char out_buffer[20];
unsigned int key;
int i, j, failed, handle, size;
TSet1 Set1[ SET1LEN ];
TSet2 Set2[ SET2LEN ];
// initialize the arrays, just to have something to work on
// the variables will have the names "SET1_0".."SET1_7"
memset( Set1, 0, sizeof Set1 );
for ( i = 0; i < SET1LEN; i++ ){
sprintf( (char*)Set1[ i ].id, "SET1_%d", i );
for ( j = 0; j < SET1COUNT; j++ ){
Set1[ i ].value[ j ] = 0.125 + i * 10.0 + j;
}
};
// the variables will have the names "SET2_0".."SET2_99"
memset( Set2, 0, sizeof Set2 );
for ( i = 0; i < SET2LEN; i++ ){
sprintf( (char*)Set2[ i ].id, "SET2_%d", i );
for ( j = 0; j < SET2COUNT; j++ ){
Set2[ i ].value[ j ] = 0.333 + i * 10.0 + j;
}
};
// first delete the file
Bfile_DeleteFile( filename );
// now save the arrays to the storage memory
size = sizeof Set1 + sizeof Set2;
failed = Bfile_CreateFile( filename, size );
locate( 1, 4 );
sprintf( (char*)out_buffer, "%d", failed );
PrintLine( out_buffer, 21 );
GetKey( &key );
if ( !failed ){
handle = Bfile_OpenFile( filename, _OPENMODE_READWRITE );
if ( handle >= 0 ){
Bfile_WriteFile( handle, Set1, sizeof Set1 );
Bfile_WriteFile( handle, Set2, sizeof Set2 );
Bfile_CloseFile( handle );
}
};
// now destroy the arrays again for verification
memset( Set1, 0, sizeof Set1 );
memset( Set2, 0, sizeof Set2 );
// reload the arrays from storage memory
handle = Bfile_OpenFile( filename, _OPENMODE_READ );
if ( handle >= 0 ){
Bfile_ReadFile( handle, Set1, sizeof Set1, -1 );
Bfile_ReadFile( handle, Set2, sizeof Set2, -1 );
Bfile_CloseFile( handle );
};
// verify: f. i. find SET1_3 and display its third value
for ( i = 0; i < SET1LEN; i++ ){
if ( strcmp( (char*)Set1[i].id, "SET1_3" ) == 0 ){
locate( 1, 4 );
sprintf( (char*)out_buffer, "%f", Set1[i].value[2] );
// should be 32.125
PrintLine( out_buffer, 21 );
GetKey( &key );
}
}
// verify: f. i. find SET2_33 and display its second value
for ( i = 0; i < SET2LEN; i++ ){
if ( strcmp( (char*)Set2[i].id, "SET2_33" ) == 0 ){
locate( 1, 4 );
sprintf( (char*)out_buffer, "%f", Set2[i].value[1] );
// should be 331.333
PrintLine( out_buffer, 21 );
GetKey( &key );
}
}
.
.
.
Simon, making great progress thanks to you

I have some nice looking bitmap menus with selectable options and goto commands to activate the function.
I want to know how I start to incorperate the memory example like above. I have added it to memory.cpp, which might be wrong? How do I then call the function?
Thanks

"The trouble with internet quotations, is that the majority are totally made up." - Abraham Lincoln 1863
- SimonLothar
- Senior Member
-
- Posts: 605
- Joined: Sat Sep 15, 2012 6:59 am
- Location: Krautland ****
- Calculators: Casio fx-7400GII, Casio fx-7400GII (SH4), Casio fx-9750GII, Casio fx-9750GII (SH4), Casio fx-9860G, Casio fx-9860G SD, Casio fx-9860G Slim, Casio fx-9860GII SD, Casio fx-9860GII SD Power Graphic 2, Casio Classpad 330 plus, Casio fx-CG20, Casio fx-CG50, Casio Classpad fx-CP400
Re: Need some newbie help please
No this is not wrong. But the snippet I dropped was only rudimental. We need proper data handling functions for your data model. And I am still on the main memory access module, which is nearly ready.MrMagoo wrote:I have added it to memory.cpp, which might be wrong? How do I then call the function?
Although it may take a bit more time, I think the data model and the necessary functions should be combined in some object oriented module. I am preparing the thing.
I'll be back!
- MrMagoo
- Member
-
- Posts: 44
- Joined: Tue Jul 02, 2013 11:57 am
- Location: London
- Calculators: Casio fx-7400G, Casio fx-7400G PLUS, Casio fx-7400GII, Casio fx-9750G, Casio fx-9750G PLUS, Casio fx-9860GII
Re: Need some newbie help please
SimonLothar wrote:No this is not wrong. But the snippet I dropped was only rudimental. We need proper data handling functions for your data model. And I am still on the main memory access module, which is nearly ready.MrMagoo wrote:I have added it to memory.cpp, which might be wrong? How do I then call the function?
Although it may take a bit more time, I think the data model and the necessary functions should be combined in some object oriented module. I am preparing the thing.
No problem, very much appreciated

"The trouble with internet quotations, is that the majority are totally made up." - Abraham Lincoln 1863
Who is online
Users browsing this forum: No registered users and 18 guests