Gamestudio Links
Zorro Links
Newest Posts
Purchase A8 full licence version
by ukgamer. 04/29/26 18:09
Z9 getting Error 058
by k_ivan. 04/25/26 19:13
ZorroGPT
by TipmyPip. 04/25/26 16:09
Stooq now requires an API key
by jcl. 04/13/26 09:42
Strange "Alien" Skull created with >Knubber<
by NeoDumont. 04/10/26 18:58
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
0 registered members (), 5,733 guests, and 39 spiders.
Key: Admin, Global Mod, Mod
Newest Members
ukgamer, valino, juergenwue, VladMak, Geir
19210 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
conceptional question to strings #336328
08/03/10 06:05
08/03/10 06:05
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Hi,

I've got a conceptional question according to strings.

I just want to get some other ideas to check mine :-)

I wrote some functions for logfile writing:

Code:
void ediag(STRING* fctName, STRING* loglevel, STRING* diagStr);

void ediag_entering(STRING* fctName);

void ediag_exiting(STRING* fctName);



As you can see there's one general function to write strings into the log with additional parameters for the function name (fctName) and a log level.

Then I have 2 functions ediag_entering and ediag_exiting that should be used at the beginning and end of the functions, e.g.

Code:
void myTestFct() {
STRING* fctName = str_create("void myTestFct()");
ediag_entering(fctName);

// do some stuff here

ediag(fctName, LEVEL_DEBUG, _str("my debug message"));

// do some stuff here

ediag_exiting(fctName);
}



So far so good ... my my the problem:

STRING* fctName = str_create("void myTestFct()");

this created string has to be removed from memory at the end of the function.

I could simply do this in the ediag_exiting function, but there are also actions that depend on an entity's lifetime and don't have a proper end (they never reach ediag_exiting).

So what's the best (or good) way to handle this str_create???

B.t.w.:
I'd like to avoid something like this:
ediag_entering(_str("void myTestFct()"));
...
ediag_exiting(_str("void myTestFct()"));

Any suggestions?

Regards,
Pegamode.


Re: conceptional question to strings [Re: pegamode] #336337
08/03/10 08:09
08/03/10 08:09
Joined: Mar 2002
Posts: 1,774
Magdeburg
F
FlorianP Offline
Serious User
FlorianP  Offline
Serious User
F

Joined: Mar 2002
Posts: 1,774
Magdeburg
Well I dont really get what ur trying to accomplish here - but why should the string be removed if the function is still running?
Do you maybe mean functions running wait-loops?
like
Code:
function blabla()
{
  STRING* fctName = str_create("void myTestFct()");
  while(something)
  {
    ediag_entering(fctName);
// do some stuff here
    ediag(fctName, LEVEL_DEBUG, _str("my debug message"));
// do some stuff here
    ediag_exiting(fctName);
    wait(1);
  }
}




I <3 LINQ
Re: conceptional question to strings [Re: FlorianP] #336339
08/03/10 08:15
08/03/10 08:15
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
I don't want to remove the string while the function is still running ... I want to remove it when the function is NOT running anymore. But for some functions you don't get a proper end.

Here's an example:

Code:
action myAction() {

STRING* fctName = str_create("action myAction()");

ediag_entering(fctName);

while (me) {
// do some stuff here

ediag(fctName, LEVEL_INFO, _str("my debug message"));

// do some stuff here
}

ediag_exiting(fctName);

}



In this case ediag_exiting is never called, because the action dies with its related entity.

Re: conceptional question to strings [Re: pegamode] #336350
08/03/10 08:58
08/03/10 08:58
Joined: Mar 2002
Posts: 1,774
Magdeburg
F
FlorianP Offline
Serious User
FlorianP  Offline
Serious User
F

Joined: Mar 2002
Posts: 1,774
Magdeburg
you need to set proc_mode to proc_global. (in fact this should be done always)
Then the action is not instantly terminated after removing the entity and your
while(me) statement gets a use as it is only in this case able to become false (otherwise u should use while(1) )


I <3 LINQ
Re: conceptional question to strings [Re: FlorianP] #336351
08/03/10 09:14
08/03/10 09:14
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Ah ... ok, I haven't seen that proc_global is available since A7.76.

This helps me a lot, thanks.

Re: conceptional question to strings [Re: pegamode] #336360
08/03/10 11:35
08/03/10 11:35
Joined: Jan 2004
Posts: 3,023
The Netherlands
Helghast Offline
Expert
Helghast  Offline
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
This helped me alot as well, thanks!


Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/
Re: conceptional question to strings [Re: Helghast] #336365
08/03/10 12:52
08/03/10 12:52
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
I had just the idea to do the following:

Instead of using

STRING* fctName = str_create("...");

I can use

#define fctName _str("...")

Then I don't have to care about removing the string.


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1