summaryrefslogtreecommitdiff
path: root/systems/msdos/tx/src/txprompt.c
blob: d68336f96f6ddc9abb9884cd5cebe1a7ff8cf697 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <conio.h> 
#include <stdlib.h> 
 
void UserPrompt(char *message, char *answer,int NumChars) 
{  
  /* Prompt user with message and put an answer of no more than NumChars */ 
  /* in the object pointed to by answer (an int or a char string) */ 
 
  char *TextInLine, *buffer, *ptr ; 
  int row, col ; 
 
  row = wherey() ; col = wherex() ;   /* save cursor position */ 
  buffer = (char *) calloc(NumChars+2,sizeof(char));
  TextInLine = (char *) malloc(161);
  gettext(1,25,80,25,TextInLine);
  gotoxy(1,25) ; 
  clreol() ;                          /* clear last line */ 
  cputs(message) ;                    /* write prompt */ 
  *buffer = NumChars ; 
  ptr = cgets(buffer) ; 
  strcpy(answer,ptr) ;                /* answer is a pointer to a string */ 
  puttext(1,25,80,25,TextInLine) ;    /* restore last line */ 
  gotoxy(col,row) ;                   /* restore cursor position */ 
  free(buffer) ; 
  free(TextInLine) ; 
  return ; 
}