Running an instance of a process.

Started by Sslaxx, May 13, 2011, 03:25:19 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Sslaxx

OK, so for a simple process-using program so far I have this:

/*
 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:
Quote from: 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.
Stuart "Sslaxx" Moore.

SplinterGU

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

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

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

#4
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?
Stuart "Sslaxx" Moore.

SplinterGU

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

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

Quote from: handsource-dyko on May 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.

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

Oops. I meant you can do things like:



int my_proc=proc(x,y);