[Gambas-user] A few questions.

Benoit Minisini gambas at ...1...
Wed Dec 22 11:05:33 CET 2004


On Wednesday 22 December 2004 00:53, Oliver Stieber wrote:
> Hi,

Hi,

> I'm a bit of an old-skool vb progammer, I've used VB
> since version 2 and even the dos version! and I've
> been trying to get to grips with Gambas with the hopes
> of porting some of my old work.

Welcome to Gambas :-)

>
>
> Anyhow, I've been having a few teething problems.
>
> 1: How do I create a type safe array of object and
> pass it as a parameter to a function e.g.
>
> public sub dosomething(optional things as type[] =
> null)
>

You can't.

>
>
> 2: I've tried a 'work around' of creating a class
> types that inherits object[], I've overridden? the add
> function so that I can add a key and value (I know I
> can do this with a collection, but I want to be able
> to get the keys back too)
>
> PUBLIC SUB add(key AS String, value AS Variant)
>  DIM aparam AS  Object
>  aparam = NEW parameter(key,value)
>
> which is find, but how do I call the object[] to add
> I've tried  add(aPARAM)  but it doesn't work...

You can do what you did in your next mail, or you can put the array inside 
your class as a private dynamic variable, without using inheritance.

>
> Also when I try to perform array access on my class it
> fails, reporting class is not an array.

It is actually possible by defining the "_get" method, but I disabled it for 
the 1.0 version.

PUBLIC FUNCTION _get(Index AS Integer) AS <Type>

will raise an error while compiling.

>
>
> 3: I've also been playing around with some graphics
> and couldn't find a way to read the value of a pixel,
> is this possible?

First, you must understand the difference between a picture stored on the X 
Server (Picture class) and a picture stored in the process memory (Image 
class). You can only modify a pixel on an Image object. To modify a pixel on 
a Picture object, you must: convert the Picture to an Image, modify the 
pixel, and then convert the Image to the Picture - It is a very heavy 
process!

>
>
> 4: where can I request some which list functions...
> the kind of things I always seem to re-write, like
> (and I know this is a hack)
>
> PUBLIC FUNCTION ang(xvalue AS Float, yvalue AS Float)
> AS Float
>
>   DIM tanvalue AS Float
>   IF xvalue = 0 THEN
>     tanvalue = 90
>   ELSE
>     tanvalue= Deg(ATan(yvalue/xvalue))
>   END IF
>   IF tanvalue < 0 THEN tanvalue = tanvalue + 360
>   IF xvalue > 0  THEN
>     tanvalue = tanvalue + 180
>   END IF
>   IF tanvalue > 360 THEN tanvalue = tanvalue - 360
>
>   RETURN tanvalue
>
> END
>
> and
>
> PUBLIC FUNCTION mag(xvalue AS Float, yvalue AS Float)
> AS Float
>
>   RETURN  Sqr(xvalue*xvalue + yvalue*yvalue)
>
> END
>

There - I will insert them in the TODO list.

Note that I try to keep the interpreter size under 150K, so I don't try to 
insert as many functions as possible inside.

What does exactly your ang() function ?

>
> 5: I've also done C/C++ for quite a few years too so I
> don't mind helping out where I can (though I don't
> really have time to get drawn into to many projects)

Come on :-)

>
> 6: While I'm porting the apps I'll try to keep a log
> of VB->Gambas issues and try to periodically
> consolidate things, I'll post it as I go if you want.

Very good idea.

>
> 7: The apps are old but quite interesting (no db stuff
> thought, mostly VB3 he he) and are as follows.
>
> A full GUI fractal landscape, tree and vista generator
> for povray, featuting FFT, many 2d graphic
> manipulation functions, 3d preview and that kind of
> thing, all in vb3, with some c helper libraies (that I
> can redo in VB).
>
> screen short here
> http://www.oliverthered.f2s.com/fractalworlds/
>
> A simple visual component based logic simulator(put
> lots of gates on the form, join the inputs and
> outputs).
>
> A photograpic database (for photographers), a standard
> database but with spline based vector graphics for
> modeling you set.
>
>
> Loads of other stuff too, adventure game generators,
> AI's to solve mine-sweeper, maybe the odd byte code
> interpreter, a RTF WISIWYG editor. that kind of thing.
>
>
> Your more than welcome to include any of the
> applications/demos with Gambas, they haven't made me
> any money over the past 15 years(but they've got me a
> quite a few jobs!).
>

Tell me when you succeed in your port, I think they could be become very good 
examples!

Regards,

-- 
Benoit Minisini
mailto:gambas at ...1...




More information about the User mailing list