Autor Tema: Running an instance of a process.  (Leído 1846 veces)

Sslaxx

  • Newbie
  • *
  • Mensajes: 34
  • Karma: 0
Running an instance of a process.
« en: Mayo 13, 2011, 03:25:19 pm »
OK, so for a simple process-using program so far I have this:

Código: [Seleccionar]
/*
  LinuxLander/BennuGD
*/

import "mod_say"

Const
 MoveBaseStart = 3; // The starting value for moving the vertical base.
End

Declare Process Test ()
 Private
 End
 Public
 End
End

Global
 int GameState = 0; /**< 0 = playing, 1 = win, -1 = went off edges of screen, -2 = missed the base. */
 int PlayerX = 0; /* The player's X location. */
 int PlayerY = 0; /* Player's Y location. */
 int BaseX = 0; /* As for the player... */
 int BaseY = 0; /* ...but detailing the base's location. */
 int MoveBaseX = 0; /* Controls the horizontal movement of the base. */
 int MoveBaseY = MoveBaseStart; /* Vertical base movement. */
 Test ItsATest; // This is where uncommenting the line below gives an error.
End

Process Main ()
Public
 int a = 0;
Private
Begin
// ItsATest (); // Uncommenting this line causes the compiler to give an error.
 Test ();
 frame;
OnExit
 say ("Thanks for playing!");
End

Process Test ()
Begin
 say (id);
 frame;
End

What I want to know is - how does BennuGD call an instance of a process (like ItsATest)? Can it? It can call the process itself, but attempting to call the instance of the process gives:
Cita de: bgdc LinuxLander.prg
/home/stuart/tmp/2/LinuxLander.prg:26: error: Undefined procedure ( token error: "ITSATEST" ).
Is what I'm asking possible? I'm wondering if the signal command would do what I want, but I'm not sure. Advice?

Interestingly, this is not the line that causes the error, that's the ItsATest (); statement.
« última modificación: Mayo 13, 2011, 03:28:19 pm por Sslaxx »
Stuart "Sslaxx" Moore.

SplinterGU

  • Hero Member
  • *****
  • Mensajes: 12893
  • Karma: 377
Re: Running an instance of a process.
« Respuesta #1 en: Mayo 13, 2011, 03:27:47 pm »
but if you don't have any procedure named IsATest... you have a procedure named Test.
Download Lastest BennuGD Release: http://www.bennugd.org/node/2

Sslaxx

  • Newbie
  • *
  • Mensajes: 34
  • Karma: 0
Re: Running an instance of a process.
« Respuesta #2 en: Mayo 13, 2011, 03:34:47 pm »
The example here - http://wiki.bennugd.org/index.php?title=ProcessID - intimates that this should be possible, though? As it calls the functions of an instance of the process and not of the process itself?

So how do multiple instances of a process work? Or am I totally misunderstanding how a process works here? Most of my programming knowledge is with C++ and languages that handle classes in a similar way. It's pretty obvious that classes != processes, just need to understand how processes work.
Stuart "Sslaxx" Moore.

SplinterGU

  • Hero Member
  • *****
  • Mensajes: 12893
  • Karma: 377
Re: Running an instance of a process.
« Respuesta #3 en: Mayo 13, 2011, 03:40:20 pm »
here

Test ItsATest; // This is where uncommenting the line below gives an error.

you don't define a procedure, you only define a variable that can be used for access to public vars of procedure named Test.
Download Lastest BennuGD Release: http://www.bennugd.org/node/2

Sslaxx

  • Newbie
  • *
  • Mensajes: 34
  • Karma: 0
Re: Running an instance of a process.
« Respuesta #4 en: Mayo 13, 2011, 03:53:38 pm »
Makes sense.

So you can't have multiple instances of a process, am I correct? That said, seeing as I barely know the language so far I haven't any idea of how to do what I want with Bennu. But I don't know where to look to find out more. Any advice?
« última modificación: Mayo 13, 2011, 03:58:40 pm por Sslaxx »
Stuart "Sslaxx" Moore.

SplinterGU

  • Hero Member
  • *****
  • Mensajes: 12893
  • Karma: 377
Re: Running an instance of a process.
« Respuesta #5 en: Mayo 13, 2011, 04:08:33 pm »
you can have multiples instances of a process... you must call it the times that you wish.

p.e.

begin

Test(); // first instance
Test(); // second instance
Test(); // third instance

...

end

the problem with your test procedure is that it start, say a text, and exit... you must use a loop with a frame if you want that it still alive.
Download Lastest BennuGD Release: http://www.bennugd.org/node/2

handsource-dyko

  • Hero Member
  • *****
  • Mensajes: 568
  • Karma: 32
  • I'm the eye in the sky.
    • dyko designs
Re: Running an instance of a process.
« Respuesta #6 en: Mayo 13, 2011, 07:00:25 pm »
And, you can store the processes unique identification code (id) in a integer variable for use in functions that interact with processes.
Also processes have a parent/child relationship.

SplinterGU

  • Hero Member
  • *****
  • Mensajes: 12893
  • Karma: 377
Re: Running an instance of a process.
« Respuesta #7 en: Mayo 13, 2011, 07:06:05 pm »
And, you can store the processes unique identification code (id) in a integer variable for use in functions that interact with processes.
Also processes have a parent/child relationship.

NO!

you can't store any value in id local var, you can use it (read), but the value of this var is set by the bennugd's core automaticly
Download Lastest BennuGD Release: http://www.bennugd.org/node/2

handsource-dyko

  • Hero Member
  • *****
  • Mensajes: 568
  • Karma: 32
  • I'm the eye in the sky.
    • dyko designs
Re: Running an instance of a process.
« Respuesta #8 en: Mayo 13, 2011, 08:02:57 pm »
Oops. I meant you can do things like:

Código: [Seleccionar]

int my_proc=proc(x,y);