libseed-list Defining a gchar in seed?
- From: alsaf <alfraealba googlemail com>
- To: Seed - Gnome Javascript <libseed-list gnome org>
- Subject: libseed-list Defining a gchar in seed?
- Date: Sat, 06 Feb 2010 11:48:44 +0000
I'm embarrassed to ask such a simple question but how do you define a
gchar variable in Seed?
The reason I am asking is that I have been mucking about with the GLib
library and get an error with one of the functions.
I've managed to get string functions working in seed by using the
following:
glib = imports.gi.GLib;
my_str = glib.string_new("test");
print (my_str.str);
my_str = glib.string_ascii_up(my_str);
print (my_str.str);
But when I try the following function associated with gchar;
text = "a";
text = glib.ascii_toupper(text);
I get the following error message:
ConversionError Can not convert Javascript value to gchar
But when I use the following command and use the Ascii value of 'a':
print (glib.ascii_toupper(97));
I get the value 65 which is the Ascii value of 'A'.
I don't have much knowledge of JavaScript so I done a quick quick and I
get the impression there is not such a char data type as such but you
can get it via the charAt() function. I tried the following code but got
the same error.
var string = "test";
a = string.charAt(1);
print (glib.ascii_toupper(a));
I appreciate it is something simple and grateful for any help given.
For reference, I've written some C code which shows the function working
#include <glib.h>
int main (int argc, char *argv[])
{
gchar text;
text = 'a';
g_printf ("Old text=%c\n", text);
text = g_ascii_toupper(text);
g_printf ("New text=%c\n", text);
}
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]