GS application

Tony Pedley tonyp@REDACTED
Wed Oct 25 10:51:29 CEST 2000


Try this instead


-module(line2).
-export([start/0, internal/0]).

start() ->
        spawn(line2, internal, []).

internal() ->
    I = gs:start(),
    Win = gs:window(I, [{map,true},{title, "Demo"}, {width, 200}, {height,270}]),
    Path = [{10,50}, {30, 50}, {30, 60}, {60, 60}],
    Canvas = gs:canvas(Win,[]),
    gs:line(Canvas,[{width,2}, {coords,Path}]),
    gs:config(Win, {map, true}).
    loop().

loop() ->
    receive
 Any ->
     ok
    end,
    loop().

To add to Francesco comments  You must have some sort of  loop at the end to ensure the process will
not end prematurely Otherwise your window will be destroyed.

All the best

Tony

Francesco Cesarini wrote:

> Hi Priya,
> you have an error in your code. What happens is that a new process is
> spawned, but it crashes when executing .
>
> gs:draw_line(Win, solid, 2, Path)
>
> Which does not exist.
>
> The error is not detected at compile time because Erlang modules are
> compiled on a stand alone basis and not linked to each other.
>
> You can easily find the error by calling internal/0 directly from the
> shell
> 6> line2:internal().
> ** exited: {undef,{gs,draw_line,
>
> [{5,<0.45.0>},solid,2,[{10,50},{30,50},{30,60},{60,60}]]}} **
> 7>
>
> Other errors include the fact that line takes a canvas as a parent and
> not a Window. Look at the online documentation @
> http://www.erlang.org/doc/current/lib/gs-1.3.7/doc/index.html for exact
> parameters to pass to the function.
>
> Regards,
> Francesco
> --
> Francesco Cesarini
>
> Erlang/OTP consultant
> Cellular: INT+44-7776 250381
> ECN: 832-707192
> http://welcome.to/cesarini.consulting
>
> Priya Paramasevam wrote:
> >
> > hello
> >
> > i did it again .. i accidentally sent the mail without completing it.
> > i have compiled and run some of the example programs provided together
> > with GS. they run fine. but when i test a simple program that i wrote
> > myself, i can't seem to see the output.
> >
> > here is my code:
> >
> > -module(line2).
> > -export([start/0, internal/0]).
> >
> > start() ->
> >         spawn(line2, internal, []).
> >
> > internal() ->
> >         I = gs:start(),
> >         Win = gs:window(I, [{title, "Demo"}, {width, 200}, {height,
> > 270}]),
> >         Path = [{10,50}, {30, 50}, {30, 60}, {60, 60}],
> >         gs:draw_line(Win, solid, 2, Path),
> >         gs:config(Win, {map, true}).
> >
> > there isn't any problem compiling, but there is no output. can you please
> > tell me what is wrong?
> >
> > thank you so much and sorry for the redundant meaningless mails.
> >
> > Kind Regards,
> > Priya Paramasevam
> > Master of Applied Science (IT)
> > RMIT University,
> > Melbourne, Australia.
> >
> >
> > ==========================================================================
> >   A good sense of humour, a big dose of patience, and a dash of humility,
> >                    you will be rewarded many-fold!
> > ==========================================================================
> >
> > On Tue, 24 Oct 2000, Simon Bennett wrote:
> >
> > > Gerald Biederbeck wrote:
> > >
> > > > I installed GS and Erlang too.
> > > > It works fine.
> > > >
> > > > Priya Paramasevam wrote:
> > > >
> > > > >   I am using Erlang to develop a simulation. I need to use GS for this. I
> > > > > have installed Erlang and GS on my computer. Unfortunately, I am not able
> > > > > to view the GS window.
> > >
> > > What I think Gerald is saying is that you have not given people on the
> > > list much to go on....
> > >
> > > For example:
> > >
> > > What operating system are you using?
> > >
> > > What version of Erlang are you using?
> > >
> > > Is OTP installed as part of the Erlang installation or separately?  If
> > > the latter, have you installed it?
> > >
> > > What have you actually done to test it?  Run an existing program?
> > > Written your own program?  Entered commands in the shell?
> > >
> > > What was the response?  Did any error messages appear anywhere?
> > >
> > > Simon Bennett
> > > Information Systems Consultant
> > > ___________________________________________________________________
> > >
> > >  Simon Bennett            E-mail:     simonb@REDACTED
> > >  Ericsson Intracom       http://www.ericsson.co.uk/UK/intracom
> > >  1 Bede Island Road       Voice (UK)  0116 2542400
> > >  Leicester                Voice (int) +44 116 2542400
> > >  England                  Voice ECN:  832 707 ext 232
> > >  LE2 7EU                  Fax:        +44 (0)116 2046111
> > > ___________________________________________________________________
> > >
>
> --
> Francesco Cesarini
>
> Erlang/OTP consultant
> Cellular: INT+44-7776 250381
> ECN: 832-707192

--
______________________________________________________________________
Tony Pedley             mailto:tonyp@REDACTED
Ericsson Intracom Ltd.  Intranet : http://intracom.ericsson.se
1 Bede Island           Internet : http://www.ericsson.co.uk/datacom/index.htm
Leicester               memoID  : ECOM.CBERAM
England                 Tel  : +44 (0)116 2 542 400
LE2 7EU                 Fax  : +44 (0)116 2 046 111
______________________________________________________________________


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20001025/db975b0e/attachment.htm>


More information about the erlang-questions mailing list