Casio Basic to SDK
- 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
nagarajan wrote:Its with the Print("Hello World"); statement.
Try
Print( (unsigned char*)"Hello World" );
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
nagarajan wrote:Ya its working fine.
Next tutorial?
Now we could try basic input/output
(I have no SDK here, so I couldn't test the code)
- Code: Select all
unsigned char c;
int key;
while( 1 ){ // start an indefinite loop
GetKey( &key ); // wait for some key to be hit
if ( ( key < KEY_CHAR_0 ) || ( key > KEY_CHAR_9 ) ) break; // quit the loop, if the key is outside of 0..9
c = key; // prepare output; PrintC needs an unsigned char* as input
PrintC( &c ); // print the key
};
As for KEY_CHAR_0 and KEY_CHAR_9: include keyboard.h.
BTW.: I deleted the previous two posts, because they were confusing.
I'll be back!
- nagarajan
- Member
- Posts: 48
- Joined: Mon Apr 23, 2012 3:58 am
- Location: Chennai,India
- Calculators: Casio fx-9750GII, Casio fx-9860G Slim, Casio fx-9860GII
- Code: Select all
int AddIn_main(int isAppli, unsigned short OptionNum)
{
unsigned char c;
int key;
while( 1 )
{
GetKey(&key );
if ((key<KEY_CHAR_0) || (key>KEY_CHAR_9)) break;
c=key;
PrintC( &c ); // print the key
}
return 1;
}
As for KEY_CHAR_0 and KEY_CHAR_9: include keybios.h.
I made some modifications and its working fine.
It is not accepting values more than 10.
What is next simon?
- 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
Now we will encapsulate the input as function
(I still cannot test the code. I hope it works.)
If it works, try to implement the DEL-key (KEY_CTRL_DEL) in myinput.
(I still cannot test the code. I hope it works.)
- Code: Select all
int myinput( unsigned char*buffer, int maxsize ){
unsigned char c;
int key;
int index=0;
int lcontinue = 1;
while( lcontinue ){
GetKey(&key );
switch (key){
case KEY_CHAR_0 :
case KEY_CHAR_1 :
case KEY_CHAR_2 :
case KEY_CHAR_3 :
case KEY_CHAR_4 :
case KEY_CHAR_5 :
case KEY_CHAR_6 :
case KEY_CHAR_7 :
case KEY_CHAR_8 :
case KEY_CHAR_9 :
c=key;
locate( index+1, 1 ); // position the cursor
PrintC( &c ); // print the key
buffer[ index ] = c; // store the key
if ( index < maxsize - 1 ) index++;
break;
case KEY_CTRL_EXIT :
case KEY_CTRL_EXE :
case KEY_CTRL_QUIT :
lcontinue = 0; // quit the loop
break;
};
}
index++;
buffer[ index ] = 0; // terminate the ASCIIZ-string
return key;
}
#define BUFFERSIZE 9
int AddIn_main(int isAppli, unsigned short OptionNum)
{
unsigned char buffer[ BUFFERSIZE ];
while(1){ // infinite loop
locate( 1, 1 );
if ( myinput( buffer, BUFFERSIZE ) == KEY_CTRL_EXE ){
// now "process" the string
locate( 1, 2 );
PrintLine( buffer, 21 ); // print the buffer and clear the rest of the line
}else{
locate( 1, 2 );
PrintLine( (unsigned char*)"", 21 ); // clear the line
};
};
return 1;
}
If it works, try to implement the DEL-key (KEY_CTRL_DEL) in myinput.
I'll be back!
- nagarajan
- Member
- Posts: 48
- Joined: Mon Apr 23, 2012 3:58 am
- Location: Chennai,India
- Calculators: Casio fx-9750GII, Casio fx-9860G Slim, Casio fx-9860GII
Hi Simon,
I tried that code.
I also implemented the KEY_CTRL_DEL but after entering the values If I press DEL key the numbers are not getting deleted.
Also the screen is not clearing and its getting overlapped in the same line.
I tried that code.
I also implemented the KEY_CTRL_DEL but after entering the values If I press DEL key the numbers are not getting deleted.
Also the screen is not clearing and its getting overlapped in the same line.
- Code: Select all
#include "fxlib.h"
#include "keybios.h"
int myinput( unsigned char*buffer, int maxsize )
{
unsigned char c;
int key;
int index=0;
int lcontinue = 1;
while( lcontinue )
{
GetKey(&key );
switch (key)
{
case KEY_CHAR_0 :
case KEY_CHAR_1 :
case KEY_CHAR_2 :
case KEY_CHAR_3 :
case KEY_CHAR_4 :
case KEY_CHAR_5 :
case KEY_CHAR_6 :
case KEY_CHAR_7 :
case KEY_CHAR_8 :
case KEY_CHAR_9 :
c=key;
locate( index+1, 1 ); // position the cursor
PrintC( &c ); // print the key
buffer[ index ] = c; // store the key
if ( index < maxsize - 1 ) index++;
break;
case KEY_CTRL_EXIT :
case KEY_CTRL_EXE :
case KEY_CTRL_QUIT :
case KEY_CTRL_DEL:
lcontinue = 0; // quit the loop
break;
};
}
index++;
buffer[ index ] = 0; // terminate the ASCIIZ-string
return key;
}
#define BUFFERSIZE 9
int AddIn_main(int isAppli, unsigned short OptionNum)
{
unsigned char buffer[ BUFFERSIZE ];
while(1)
{ // infinite loop
locate( 1, 1 );
if ( myinput( buffer, BUFFERSIZE ) == KEY_CTRL_EXE )
{
// now "process" the string
locate( 1, 2 );
PrintLine( buffer, 21 ); // print the buffer and clear the rest of the line
}
else
{
locate( 1, 2 );
PrintLine( (unsigned char*)"", 21 ); // clear the line
};
};
return 1;
}
- 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
If you want to clear the screen, use Bdisp_AllClr_VRAM()
to support the DEL-key you have to enter some code, which performs the DEL-operation
- Code: Select all
int AddIn_main(int isAppli, unsigned short OptionNum)
{
unsigned char buffer[ BUFFERSIZE ];
Bdisp_AllClr_VRAM(); // clear the screen
while(1)
{ // infinite loop
locate( 1, 1 );
.
.
.
to support the DEL-key you have to enter some code, which performs the DEL-operation
- Code: Select all
.
.
.
switch (key)
{
case KEY_CHAR_0 :
case KEY_CHAR_1 :
case KEY_CHAR_2 :
case KEY_CHAR_3 :
case KEY_CHAR_4 :
case KEY_CHAR_5 :
case KEY_CHAR_6 :
case KEY_CHAR_7 :
case KEY_CHAR_8 :
case KEY_CHAR_9 :
c = key;
buffer[ index ] = c; // store the key
if ( index < maxsize - 1 ) index++; // increase the index, if not already at the end
buffer[ index ] = 0; // terminate the string
locate( 1, 1 ); // set the cursor to the begin of the line
PrintLine( buffer, 21 ); // print the complete line
break;
case KEY_CTRL_DEL:
if ( index > 0 ) index--; // decrease the index, if not already at the end
buffer[ index ] = 0; // delete the key
locate( 1, 1 ); // set the cursor to the begin of the line
PrintLine( buffer, 21 ); // print the complete line
break;
case KEY_CTRL_EXIT :
case KEY_CTRL_EXE :
case KEY_CTRL_QUIT :
lcontinue = 0; // quit the loop
break;
};
}
.
.
.
I'll be back!
Who is online
Users browsing this forum: No registered users and 40 guests