FredTheFred Posted August 17, 2015 Share Posted August 17, 2015 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... Quote Link to comment Share on other sites More sharing options...
Pixelboy Posted August 17, 2015 Share Posted August 17, 2015 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. Quote Link to comment Share on other sites More sharing options...
FredTheFred Posted August 17, 2015 Author Share Posted August 17, 2015 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. Quote Link to comment Share on other sites More sharing options...
FredTheFred Posted August 17, 2015 Author Share Posted August 17, 2015 I found another way to do it by : const byte us[]={0x5F}; // define underscore _ for example put_at(0,0,us,1); // For display us variable It work fine like this. Quote Link to comment Share on other sites More sharing options...
Pixelboy Posted August 17, 2015 Share Posted August 17, 2015 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. 1 Quote Link to comment Share on other sites More sharing options...
FredTheFred Posted August 17, 2015 Author Share Posted August 17, 2015 char c = 'A'; put_char(15,11,c); Yes i've already try this alternative code but it's dont work too... Quote Link to comment Share on other sites More sharing options...
Kiwi Posted August 18, 2015 Share Posted August 18, 2015 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(){ } Quote Link to comment Share on other sites More sharing options...
FredTheFred Posted August 18, 2015 Author Share Posted August 18, 2015 Yep ! it's work fine. I keep this example. Thanks Quote Link to comment Share on other sites More sharing options...
GroovyBee Posted August 18, 2015 Share Posted August 18, 2015 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. Quote Link to comment Share on other sites More sharing options...
Kiwi Posted August 18, 2015 Share Posted August 18, 2015 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. Quote Link to comment Share on other sites More sharing options...
+nanochess Posted August 18, 2015 Share Posted August 18, 2015 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.