Jump to content
IGNORED

What's wrong with char_put void ?


FredTheFred

Recommended Posts

Hello all

 

I've got a problem to display a character by using put_char void. In the documentation i can read this :

void put_char (byte x,byte y,char s);
Example:
char c;
c = 'A';
put_char(15,11,c);
I understand char c to define c like a character type variable, c='A' c variable equals A character and put_char to display c variable at x/y location.
but when i try to complie the void in my program, SDCC return an error : syntax error: token -> '=' ; column 4 !
what's wrong for me ?
Thanks you all for help again...

 

Link to comment
Share on other sites

Is that your actual real code, or just a generic example? Your example code seems fine to me anyway...

 

That kind of error message usually indicates that there's something wrong with the line above the line number indicated.

It's a generic example taken from documentation. I just get it back in my own program to test the command -

In my program, inside include library i put char c; c = 'A'; and in a routine i put put_char(15,11,s);

and it doesn't work.

Link to comment
Share on other sites

It's a generic example taken from documentation. I just get it back in my own program to test the command -

In my program, inside include library i put char c; c = 'A'; and in a routine i put put_char(15,11,s);

and it doesn't work.

Have you tried this, by any chance?

 

char c = 'A';
put_char(15,11,c);

If I'm not mistaken, standard C language doesn't allow any instructions above variable definitions. You have to define all your variables at the beginning of the function, and the rest of the function are your instructions. I'm not 100% sure about that though, but anyway, when I code in C, I always define all variables at the beginning of each function. :)

  • Like 1
Link to comment
Share on other sites

Here's a working example how put_char works. I usually declare several temporary variables globally since I reuse them constantly. Byte and char variables works with the put_char function.

#include <coleco.h>
#include <getput1.h>

byte a;

char letter;

void main(void){

screen_mode_2_text();

screen_on();
disable_nmi();
upload_default_ascii(BOLD);
fill_vram(0x2000,0x90,2048);
a='B';
put_char(3,3,a);
letter='A';
put_char(4,4,letter);
pause();
}
void nmi(){
}
Link to comment
Share on other sites

Can't you change this :-

 

 

a='B';
put_char(3,3,a);
letter='A';
put_char(4,4,letter);

 

to this :-

 

put_char(3,3,'B');
put_char(4,4,'A');
It seems a bit odd to use a variable to hold a constant. If you were writing out a string using *ptr++ then that would be different.
Link to comment
Share on other sites

Can't you change this :-

 

to this :-

 

put_char(3,3,'B');
put_char(4,4,'A');
It seems a bit odd to use a variable to hold a constant. If you were writing out a string using *ptr++ then that would be different.

 

Yes you can. You can also,

number=4;

You can also do, put_char(5,5,number+48); to print what number the variable is holding. I used this to print single number on screen.

Link to comment
Share on other sites

Hello all

 

I've got a problem to display a character by using put_char void. In the documentation i can read this :

void put_char (byte x,byte y,char s);
Example:
char c;
c = 'A';
put_char(15,11,c);
I understand char c to define c like a character type variable, c='A' c variable equals A character and put_char to display c variable at x/y location.
but when i try to complie the void in my program, SDCC return an error : syntax error: token -> '=' ; column 4 !
what's wrong for me ?
Thanks you all for help again...

 

 

It looks like a bug in SDCC.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...