Path: utzoo!attcan!uunet!lll-winken!elroy.jpl.nasa.gov!zardoz.cpd.com!tmiuv0!rick From: rick@tmiuv0.uucp Newsgroups: comp.sys.amiga Subject: Re: Help with C!!!! Message-ID: <3615@tmiuv0.uucp> Date: 26 Jul 90 11:32:05 GMT References: <28589@cc.usu.edu> Organization: Technology Marketing Inc., Irvine, CA Lines: 45 In article <28589@cc.usu.edu>, SLMT9@cc.usu.edu writes: > This is a question to all of you C guru's out there. Is there a way > to place the CURSOR in a predetermined spot on the screen. Say move it from > the bottom right hand corner to the upper left to write in that location again > something like the LOCATE command in basic. > I would really appriciate any help that anyone can give me. > > Joshua > SLMT9@cc.usu.edu Try this (an ANSI escape sequence): printf("\033[10;21H"); That will place the cursor on line 10, column 21 of the screen. The ANSI escape sequence is defined as: y;xH where can be either a hexadecimal 9b or an escape character (0x1b or octal 33) followed by a '[' character. The y refers to the row number which must be specified in ASCII characters, and the x is the column number (again in ASCII characters). To make this general purpose, here's a pukey function to do it: void poscursor(short row, short column) { printf("\033[%d;%dH",row,column); } To put the cursor at line 12, column 43: poscursor(12,43); The escape sequences that the console.device understands are in the ROM Kernal Manuals (RKM): Libraries and Devices volume. -- ---------------------------------------------------------------------------- [- O] Rick Stevens ? EMail: uunet!zardoz!tmiuv0!rick -or- uunet!zardoz!xyclone!sysop V CIS: 75006,1355 (75006.1355@compuserve.com from Internet) "I'm tellin' ya, Valiant! Da whole ting stinks like yesterday's diapers!" - Baby Herman in "Who Framed Roger Rabbit" ----------------------------------------------------------------------------