The time now is Wed 19 Jun 2013, 08:04
All times are UTC - 4 |
|
Page 1 of 35 Posts_count |
Goto page: 1, 2, 3, ..., 33, 34, 35 Next |
| Author |
Message |
Lobster
Official Crustacean

Joined: 04 May 2005 Posts: 15109 Location: Paradox Realm
|
Posted: Thu 12 Mar 2009, 08:41 Post_subject:
Vala and Genie programming |
|
In my desperate and futile attempts to program
I have been exploring the vala/genie programming language
used in Woof
http://live.gnome.org/Genie
I have been able to compile some of Barrys examples
http://puppylinux.com/genie/
now this:
| Code: | init
a:array of string = {"abc", "def", "xyz"}
for s in a
print(s)
|
gives me
| Quote: | # valac v5.gs
v5.c: In function '_main':
v5.c:34: error: stray '\' in program
v5.c:34:40: warning: missing terminating " character
v5.c:34: error: missing terminating " character
v5.c:34: error: 'n' undeclared (first use in this function)
v5.c:34: error: (Each undeclared identifier is reported only once
v5.c:34: error: for each function it appears in.)
v5.c:35: error: expected ')' before '_tmp2'
v5.c:37: error: expected ')' before '}' token
v5.c:37: error: expected ';' before '}' token
error: cc exited with status 256
Compilation failed: 1 error(s), 0 warning(s)
#
|
which is more errors then I can cope with . . .
I am pretty sure it is something to do with the tab
ending the program (python does this too)
but can not solve it.
HELP!
_________________ Puppy WIKI
Edited_time_total
|
|
Back to top
|
|
 |
MU

Joined: 24 Aug 2005 Posts: 13642 Location: Karlsruhe, Germany
|
Posted: Thu 12 Mar 2009, 11:28 Post_subject:
|
|
be sure to use tabs, not spaces in the beginning of the lines.
I just copied your example via copy&paste in Opera to leafpad, and it compiles fine here (newyearspup02 with devx).
Mark
_________________ my recommended links
|
|
Back to top
|
|
 |
MU

Joined: 24 Aug 2005 Posts: 13642 Location: Karlsruhe, Germany
|
Posted: Thu 12 Mar 2009, 11:31 Post_subject:
|
|
you also may compile:
valac -C v5.gs
This just creates v5.c and v5.h.
Pleae copy&paste them here.
Maybe the difference to mine show, what goes wrong for you.
Mark
_________________ my recommended links
|
|
Back to top
|
|
 |
Lobster
Official Crustacean

Joined: 04 May 2005 Posts: 15109 Location: Paradox Realm
|
Posted: Thu 12 Mar 2009, 11:34 Post_subject:
|
|
tried in leafpad
will have another go
- it is the space thing - yes
I am using 4.2 rc2
and a 64 bit processor
(and I am stupid)
v5.c
| Code: | #include "v5.h"
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
void _main (char** args, int args_length1) {
char** _tmp1;
gint a_size;
gint a_length1;
char** _tmp0;
char** a;
_tmp1 = NULL;
_tmp0 = NULL;
a = (_tmp1 = (_tmp0 = g_new0 (char*, 3 + 1), _tmp0[0] = g_strdup ("abc"), _tmp0[1] = g_strdup ("def"), _tmp0[2] = g_strdup ("xyz"), _tmp0), a_length1 = 3, a_size = a_length1, _tmp1);
{
char** s_collection;
int s_collection_length1;
int s_it;
s_collection = a;
s_collection_length1 = a_length1;
for (s_it = 0; s_it < a_length1; s_it = s_it + 1) {
const char* _tmp3;
char* s;
_tmp3 = NULL;
s = (_tmp3 = s_collection[s_it], (_tmp3 == NULL) ? NULL : g_strdup (_tmp3));
{
char* _tmp2;
_tmp2 = NULL;
g_print (_tmp2 = g_strconcat (s, \n", NULL));
_tmp2 = (g_free (_tmp2), NULL);
s = (g_free (s), NULL);
}
}
}
a = (_vala_array_free (a, a_length1, (GDestroyNotify) g_free), NULL);
}
int main (int argc, char ** argv) {
g_type_init ();
_main (argv, argc);
return 0;
}
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
if ((array != NULL) && (destroy_func != NULL)) {
int i;
for (i = 0; i < array_length; i = i + 1) {
if (((gpointer*) array)[i] != NULL) {
destroy_func (((gpointer*) array)[i]);
}
}
}
g_free (array);
} |
and v5.h
| Code: | #ifndef __V5_H__
#define __V5_H__
#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
G_BEGIN_DECLS
void _main (char** args, int args_length1);
G_END_DECLS
#endif |
Thanks Mark
_________________ Puppy WIKI
|
|
Back to top
|
|
 |
MUguest
Joined: 09 Dec 2006 Posts: 73
|
Posted: Fri 13 Mar 2009, 05:53 Post_subject:
|
|
Lob,
I get the same error trying to compile it in WinowsXP, using 0.5.7.
At home in Puppy I had used 0.5.1:
http://distro.ibiblio.org/pub/linux/distributions/puppylinux/pet_packages-4/vala-0.5.1-i486.pet
The problem is the generated C code, line 34:
| Code: | | g_print (_tmp2 = g_strconcat (s, \n", NULL)); | should be:
| Code: | | g_print (_tmp2 = g_strconcat (s, "\n", NULL)); |
So there missed a quotation mark.
Maybe with 0.5.1 you will have success.
Mark
|
|
Back to top
|
|
 |
MUguest
Joined: 09 Dec 2006 Posts: 73
|
Posted: Fri 13 Mar 2009, 06:12 Post_subject:
|
|
yes, with 0.5.1 the example compiles fine also in WinXP.
In 0.5.6 it does not.
So this is a bug in newer versions, or the syntax for the "for" loop changed.
Mark
|
|
Back to top
|
|
 |
Lobster
Official Crustacean

Joined: 04 May 2005 Posts: 15109 Location: Paradox Realm
|
Posted: Fri 13 Mar 2009, 06:46 Post_subject:
|
|
| Quote: | | yes, with 0.5.1 the example compiles |
Yep works for me too in 0.5.1
Thanks Mark
Now to program my own masterpiece . . .
_________________ Puppy WIKI
|
|
Back to top
|
|
 |
Lobster
Official Crustacean

Joined: 04 May 2005 Posts: 15109 Location: Paradox Realm
|
Posted: Fri 13 Mar 2009, 07:08 Post_subject:
|
|
stuck again
been looking for a list of reserved words
in particular functions . . .
Am trying to find and use a rnd or random function.
Any clues?
_________________ Puppy WIKI
|
|
Back to top
|
|
 |
MUguest
Joined: 09 Dec 2006 Posts: 73
|
Posted: Fri 13 Mar 2009, 09:29 Post_subject:
|
|
You can use the random method from GLib.
http://valadoc.org/?pkg=glib-2.0&element=GLib.Random
Example:
| Code: | init
// return a random value from 1 to 9
a:int
a = GLib.Random.int_range(1,10)
print("%d" , a)
|
------------------------------------------
references
http://valadoc.org/?
http://www.vala-project.org/doc/vala/
http://live.gnome.org/Vala
http://live.gnome.org/Vala/Tutorial
http://library.gnome.org/devel/glib/
Mark
|
|
Back to top
|
|
 |
MU

Joined: 24 Aug 2005 Posts: 13642 Location: Karlsruhe, Germany
|
Posted: Sat 14 Mar 2009, 05:18 Post_subject:
|
|
I attach a pet made from the Archlinux package of the vala-IDE.
http://www.valaide.org/doku.php
It requires Gtksourceview:
http://dotpups.de/puppy3/dotpups/Libraries/Gnome-2.19.2-libs/other-Libs/gtksourceview-2.0.2-i486.pet
I did not try, if it works in Puppy.
I tested it in NYP 02rc7, that has updated Gtk libraries (based on Ultrapup).
The homepage says, it requires vala 0.5.7, but it seems to work fine with 0.5.1.
Mark
| Description |
|

Download |
| Filename |
valide-0.4-1-i686.pet |
| Filesize |
824.58 KB |
| Downloaded |
1579 Time(s) |
| Description |
|
| Filesize |
66.07 KB |
| Viewed |
8239 Time(s) |

|
| Description |
|
| Filesize |
44.08 KB |
| Viewed |
8099 Time(s) |

|
_________________ my recommended links
|
|
Back to top
|
|
 |
Lobster
Official Crustacean

Joined: 04 May 2005 Posts: 15109 Location: Paradox Realm
|
Posted: Sat 14 Mar 2009, 05:49 Post_subject:
|
|
I could not get the random code to work - will try again later
Hey thanks for the IDE that looks useful . . .
only . . .
this is what I got in Deep Thought 4.20 rc3
| Code: | # ./valide
./valide: error while loading shared libraries: libgio-2.0.so.0: cannot open shared object file: No such file or directory
# |
_________________ Puppy WIKI
|
|
Back to top
|
|
 |
muggins
Joined: 20 Jan 2006 Posts: 6663 Location: lisbon
|
Posted: Sat 14 Mar 2009, 17:39 Post_subject:
|
|
libgio-2.0.so.0.pet
libselinux.so.1.pet
|
|
Back to top
|
|
 |
Lobster
Official Crustacean

Joined: 04 May 2005 Posts: 15109 Location: Paradox Realm
|
Posted: Sat 14 Mar 2009, 23:54 Post_subject:
|
|
thanks Muggins
now in rc3 of 4.2
added those pets and now getting . . .
| Code: | # ./valide
./valide: symbol lookup error: /usr/lib/libvalide-0.0.so: undefined symbol: g_dgettext
# |
_________________ Puppy WIKI
|
|
Back to top
|
|
 |
Lobster
Official Crustacean

Joined: 04 May 2005 Posts: 15109 Location: Paradox Realm
|
Posted: Sun 15 Mar 2009, 13:26 Post_subject:
|
|
Hey Mark,
Thanks for the random prog - got that working ok
I am using it to train an infinite number of monkeys on virtual typewriters to write this (to start with)
| Code: | | while myLine != "in the" |
Soon (a few billion years) they will type out the Bible and the Complete Works of Shakespeare
. . . what am I missing?
| Code: | // Infinite Monkey Theorem, Lobster and Shadow, March 2009
init
myChars:array of string = {" ", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}
myLine:string = ""
myCount:int = 6
while myLine != "in the"
for i:int = 1 to myCount
myLine = myLine.concat(myChars[GLib.Random.int_range(0,myChars.length)])
print(myLine) |
rather than using a string array - is there not some sort of more efficient string pointer?
_________________ Puppy WIKI
|
|
Back to top
|
|
 |
MU

Joined: 24 Aug 2005 Posts: 13642 Location: Karlsruhe, Germany
|
Posted: Sun 15 Mar 2009, 18:05 Post_subject:
|
|
Lobster, sorry no answer, but a request:
please do not edit your messages to add new content.
I just saw your monkey example by accident, when I looked up something in this thread.
That also had happened before, so that I replied very late.
The best is to add a new message, so that I can see it in my "View posts since last visit".
Mark
_________________ my recommended links
|
|
Back to top
|
|
 |
|
|
Page 1 of 35 Posts_count |
Goto page: 1, 2, 3, ..., 33, 34, 35 Next |
|
|
Rules_post_cannot Rules_reply_cannot Rules_edit_cannot Rules_delete_cannot Rules_vote_cannot You cannot attach files in this forum You can download files in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|