Re: Help, I need filter text in function



On Fri, 2001-08-31 at 03:28, javiercmx correo unam mx wrote:
Hi list

I write a function it admit numbers, the function is: 

void edit_clv_plt(GtkWidget *widget, gpointer data) {
  char *tmpplt;
  char ch = *((char *) data);
  char *str;
 
  str = (char *) data;
 
  if(isdigit (ch) && strlen (str) == 1) { /*introducing a number*/
     g_free(host.plt);                   
    
     /*it obtains the chain*/
     tmpplt=gtk_editable_get_chars(GTK_EDITABLE(widget),0 ,-1); 
     host.plt=g_strdup(tmpplt);
    
  } else {
    Messages("Error","Write the number");  /*Function for Show Messages*/
  }
}                                  

I don't know what your data element is, so I can't really tell you what
is wrong with your code.

The user write the numbers, in GtkEntry, the text is not allowed, the max digits
is 3, but when running the program write a text, call function Messages, if
write a number, call a function Messages, where this the error

I've attached a program that only allows you to type in digits, and only
up to three of those.  It is not a particullar good example, 'cause you
cant delete chars or move the cursor since these keys are also aborted,
but perhaps you can use it to get where you want.

        /mailund

-- 

I used up all my sick days, so I'm calling in dead.

Attachment: main5.c
Description: Text Data

Attachment: pgpVtDTJLMmTl.pgp
Description: PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]