From: "Steve" <~~steven DOT harrison AT virgin DOT net> Newsgroups: comp.os.msdos.djgpp Subject: Re: Here's my function to get a string... Date: Sat, 20 Jun 1998 23:26:26 +0100 Organization: Virgin Net Usenet Service Lines: 67 Message-ID: <6mhcqv$lc3$1@nclient3-gui.server.virgin.net> References: <358A51A3 DOT 67A96095 AT netrover DOT com> NNTP-Posting-Host: 194.168.69.34 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk I had to write a function to do just that about 4 years ago, if I can remember the code... (BTW this is using a normal Mode 0x03 screen.) void GetString(int x, iny y, char *text, int MaxLen) { int cLen = 0; char ch = 0; while(ch != 13) { ch = getch(); if(ch == 8) // Backspace key { text[cLen] = 0 cLen--; } else { text[cLen++] = ch; } } } That's the quick and dirty version, I can not remember the full error handling one I done, but the above is exactly what you were after, unfortunately it's not using algero for screen blitting or Double buffering, I'll leave that up to someone who knows how it works The above code has been typed from memory, so if it's wrong I'm sorry, but you could take it as plain pseudo code Nicolas Blais wrote in message <358A51A3 DOT 67A96095 AT netrover DOT com>... >Hi, I asked before for someone to write a function to let the user give >a string with Allegro. I already have one, but it has one major >problem; you can't use Backspaces. Is there a way to modify my function >to do so? It uses double buffering (useless but I still brag about >it...) > >void get_keys(int leftx, int topy, int Num_ch) >{ >clear(screen); >char buf[200]; >char msg[2]; >int current_num_ch = 0; >do > { > current_num_ch++; > if (current_num_ch == Num_ch) exit(0); > int value = readkey(); > sprintf(msg,"%c",(value & 0xFF)); > strcat(buf, msg); > int x = text_length(font, buf); > int y = text_height(font)+4; > BITMAP* textbmp = create_bitmap(x,y); > clear(textbmp); > textout((BITMAP*)textbmp,font,buf,0,0,RGB(255,0,0)); > blit((BITMAP*)textbmp, screen, 0,0,leftx,topy,textbmp->w,textbmp->h); > destroy_bitmap(textbmp); > } >while (!key[KEY_ENTER]); >} > >Hope you can find this error, Nicolas Blais >