D - A Bit of Help
- Rick Clark (18/18) Feb 28 2003 I am trying to learn D and I thought I would convert some C programs
- Rick Clark (183/183) Feb 28 2003 Here is the silly little C program I am trying to convert to D. The
- Burton Radons (14/32) Feb 28 2003 Those aren't the proper signatures for those symbols. I get:
- Rick Clark (3/14) Feb 28 2003 Thanks Burton, I'll give it a try.
I am trying to learn D and I thought I would convert some C programs over to D. One of them uses some console functions out of conio. I made a conio.d with the declarations the program uses and the program compiles fine, but does not link. Obviously, I am doing something wrong. Here is the error: test1.obj(test1) Error 42: Symbol Undefined _SetConsoleCursorPosition 12 test1.obj(test1) Error 42: Symbol Undefined _FillConsoleOutputCharacter 24 test1.obj(test1) Error 42: Symbol Undefined _FillConsoleOutputAttribute 24 --- errorlevel 3 I tried compiling both the test program and conio (and windows.d too, just for grins) but I get the same error during linking. The C program compiles-links fine using DMC. If someone could point me in the right direction I would appreciate it. Thanks for helping a novice. :) Rick Clark
Feb 28 2003
Here is the silly little C program I am trying to convert to D. The console functions are what I am after: positon the cursor in the console, write different colors and clear the console screen. These might already be in the language, but I couldn't find them. Thanks! Rick Clark // ************************************************************* // Original Program by Kevin Diggins // ************************************************************* #include <windows.h> #include <conio.h> #include <stdio.h> #include <string.h> COORD cursor; HANDLE hConsole; int color_fg = 7; int color_bg = 0; static char A[2048]; static char B[2048]; static char C[2048]; void cls(void); void color (int fg, int bg); void locate (int row,int col,int show); void Dance (char *A, char *B, char *C, int Dlay ); int main(void) { hConsole = GetStdHandle (STD_OUTPUT_HANDLE); cls(); color (3,0); locate (6,23,0); printf("%s\n","The Ascii Macarena Dance"); while(1) { color (9,0 ); locate (8,26,0); printf("%s\n","Press Any Key to Quit"); Sleep(500); // ---------- Step One ------------ strcpy(A," o "); strcpy(B,"^|\\"); strcpy(C," /\\"); Dance(A,B,C,3); // --------- Step Two -------------- strcpy(A," o "); strcpy(B,"^|^"); strcpy(C," >\\"); Dance(A,B,C,4); // --------- Step Three ------------- strcpy(A," o "); strcpy(B,"v|^"); strcpy(C,"/< "); Dance(A,B,C,5); // --------- Step Four --------------- strcpy(A," o "); strcpy(B,"v|^"); strcpy(C," >\\"); Dance(A,B,C,4); // --------- Step Five ---------------- strcpy(A," o "); strcpy(B,"|/^"); strcpy(C,"/< "); Dance(A,B,C,3); // ---------- Step Six ----------------- strcpy(A," o "); strcpy(B,"|-|"); strcpy(C," >\\"); Dance(A,B,C,4); // ----------- Step Seven --------------- strcpy(A," <o "); strcpy(B,"//| "); strcpy(C,"/< "); Dance(A,B,C,5); // ----------- Step Eight ----------------- strcpy(A,"<o> "); strcpy(B," | "); strcpy(C," >//"); Dance(A,B,C,4); // ----------- Step Nine ------------------ strcpy(A," o> "); strcpy(B," // "); strcpy(C,"/< "); Dance(A,B,C,3); // ----------- Step Ten ------------------ strcpy(A," o "); strcpy(B," x "); strcpy(C," >\\"); Dance(A,B,C,4); // ----------- Step Eleven --------------- strcpy(A," o "); strcpy(B,"</ "); strcpy(C,"/< "); Dance(A,B,C,5); // ----------- Step Twelve ------------------ strcpy(A," o "); strcpy(B,"<|>"); strcpy(C," >\\"); Dance(A,B,C,4); // ----------- Step Thirteen ---------------- strcpy(A," o "); strcpy(B,"</>"); strcpy(C,"/< "); Dance(A,B,C,3); // ----------- Step Fourteen --------------- strcpy(A," o "); strcpy(B,"<\\>"); strcpy(C," >\\"); Dance(A,B,C,4); // ----------- Step Fifteen --------------- strcpy(A," o "); strcpy(B,"<)>"); strcpy(C," >>"); Dance(A,B,C,4); // ----------- Step Sixteen ---------------- strcpy(A," o "); strcpy(B," )\\"); strcpy(C," LL"); Dance(A,B,C,5); } return 0; } void locate (int row,int col,int show) { CONSOLE_CURSOR_INFO cci; cursor.X = col-1; cursor.Y = row-1; SetConsoleCursorPosition(hConsole,cursor); cci.bVisible = show; SetConsoleCursorInfo(hConsole,&cci); } void cls (void) { DWORD ret; register int attr; cursor.X = 0; cursor.Y = 0; FillConsoleOutputCharacter(hConsole,32,4000,cursor,&ret); attr = color_fg + color_bg * 16; FillConsoleOutputAttribute (hConsole,attr,4000,cursor,&ret); locate(1,1,1); } void color (int fg, int bg) { SetConsoleTextAttribute (hConsole,fg+bg*16); color_fg = fg; color_bg = bg; } void Dance (char *A, char *B, char *C, int Dlay) { static int Kolor; memset(&Kolor,0,sizeof(Kolor)); if(kbhit()) { locate (1,1,1); color (7,0 ); cls(); fflush(stdout); ExitProcess(0); } color (4,0 ); color (6,0 ); locate (12,33,0); printf("%s\n",A); color (4,0 ); locate (13,33,0); printf("%s\n",B); color (9,0 ); locate (14,33,0); printf("%s\n",C); Sleep(Dlay*100); locate (24,12,0); Kolor+=1; if(Kolor==0) { Kolor++; } if(Kolor==15) { Kolor=1; } color (15,0 ); locate (8,26,0); printf("%s\n","Press Any Key to Quit"); }
Feb 28 2003
Rick Clark wrote:I am trying to learn D and I thought I would convert some C programs over to D. One of them uses some console functions out of conio. I made a conio.d with the declarations the program uses and the program compiles fine, but does not link. Obviously, I am doing something wrong. Here is the error: test1.obj(test1) Error 42: Symbol Undefined _SetConsoleCursorPosition 12 test1.obj(test1) Error 42: Symbol Undefined _FillConsoleOutputCharacter 24 test1.obj(test1) Error 42: Symbol Undefined _FillConsoleOutputAttribute 24 --- errorlevel 3 I tried compiling both the test program and conio (and windows.d too, just for grins) but I get the same error during linking. The C program compiles-links fine using DMC. If someone could point me in the right direction I would appreciate it.Those aren't the proper signatures for those symbols. I get: _SetConsoleCursorPosition 8 _FillConsoleOutputCharacterW 20 _FillConsoleOutputAttribute 20 So you should be importing them using: extern (Windows) { BOOL SetConsoleCursorPosition (HANDLE, COORD); BOOL FillConsoleOutputCharacterW (HANDLE, WCHAR, DWORD, COORD, LPDWORD); BOOL FillConsoleOutputAttribute (HANDLE, WORD, DWORD, COORD, LPDWORD); }
Feb 28 2003
Thanks Burton, I'll give it a try. Rick Burton Radons wrote:So you should be importing them using: extern (Windows) { BOOL SetConsoleCursorPosition (HANDLE, COORD); BOOL FillConsoleOutputCharacterW (HANDLE, WCHAR, DWORD, COORD, LPDWORD); BOOL FillConsoleOutputAttribute (HANDLE, WORD, DWORD, COORD, LPDWORD); }
Feb 28 2003