Once again with SCANF, but now I'm about to solve it!!!

Search this archive.

From: Nicolas Raitman (new_world@radar.com.ar)
Date: Sat 02 Sep 2000 - 22:07:34 IDT


#include <stdio.h>
#include <stdlib.h>
#include <vgakeyboard.h>
#include <math.h>
#include <vgagl.h>
#include <vga.h>
#include <string.h>
#include <unistd.h>

float convertir(void);

#define TEXT 0

float temp;
char strnum[20];
int i;

GraphicsContext *physical_screen;
GraphicsContext *virtual_screen;



int main (void)
{


extern unsigned char *gl_font8x8;

vga_disabledriverreport();
vga_init();
vga_setmode(12);
gl_setcontextvga(12);

physical_screen = gl_allocatecontext();
gl_getcontext(physical_screen);
gl_setcontextvgavirtual(12);
virtual_screen = gl_allocatecontext();
gl_getcontext(virtual_screen);
gl_setcontext(virtual_screen);
gl_setfont(8,8,gl_font8x8);
gl_setwritemode(FONT_COMPRESSED + WRITEMODE_MASKED);
gl_clearscreen(0);

i = 0;

/* the following cycle is to get the numbers, store it in a char array and
then i will convert it to a float. The problem here is that i want the
characters to be printed while the user is typing. I tried to add a
gl_printf(...) i the middle of the cycle, but i come up with some problems.
The first one is that i have to specify a position, and since this will be a
routine it can be called when the cursor is anywhere on the the screen: it
can be at x = 200, or x = 400, so what i want to do is to place the cursos
10 position to the right where it was the last time before entering the
cycle.

Please try to complete the cycle, so that while the user types he sees what
he is typing in the location i told you above. REMEBER THAT IM WORKING WITH
GRAPHICS  as you saw that i initialized above. The following code works
perfectly under textmode, but not in graphics mode.

while((strnum[i] = vga_getch()) != '\n') {
 i++;
 }

/*temp = atof(strnum);     i will use this to convert it to float */

vga_setmode(TEXT);
exit(EXIT_SUCCESS);

}


Thanks


This archive was generated by hypermail 2.1.4 : Wed 21 Jan 2004 - 22:10:23 IST