1 registered members (AndrewAMD),
1,534
guests, and 3
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Questions about: How to create a macro function?
#431706
10/22/13 18:38
10/22/13 18:38
|
Joined: Nov 2007
Posts: 318 Brasil, Paraná
NeoNeper
OP
Senior Member
|
OP
Senior Member
Joined: Nov 2007
Posts: 318
Brasil, Paraná
|
Hello friends. with the purpose of maintaining the proper functioning of my functions that are linked to a DLL, i need use the function "wait_for" always after performing some function of the dll. Sample:
int select = sql_select("SELECT * FROM terrains");
wait_for(sql_select);
if(select)
...
This Became too boring, because I need to do this many, many times throughout the script. (wait_for()...wait_for() ...) Is there any way to create a macro linked to functions? Whenever I call a function, it automatically performs another function in end?
Last edited by NeoNeper; 10/22/13 18:39.
Please! Use easy words to be translated. because my English is not very good! Grateful. _______________________________________________________
|
|
|
Re: Questions about: How to create a macro function?
[Re: Ch40zzC0d3r]
#431712
10/22/13 20:22
10/22/13 20:22
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
Chaos, I'm pretty sure Neo wanted to automate the wait_for(), not have a callback function...
Which, by the way, doesn't work. Nor does it need to, because wait_for() will always return immediately, since Neos DLL method will never ever be registered as still running in the engines Scheduler (no will it ever appear there as anything). No idea why he thought wait_for() is needed there, but it's definitely not.
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: Questions about: How to create a macro function?
[Re: Ch40zzC0d3r]
#431716
10/22/13 20:51
10/22/13 20:51
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
But why?! iSelection (by the way, you are doing hungarian notation wrong) doesn't change after sql_select was called. Ever.
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: Questions about: How to create a macro function?
[Re: Ch40zzC0d3r]
#431720
10/22/13 21:45
10/22/13 21:45
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
The code from the original poster is already flawed. That's the problem. He has misunderstood the conception of wait and return.
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Re: Questions about: How to create a macro function?
[Re: WretchedSid]
#431742
10/23/13 11:11
10/23/13 11:11
|
Joined: Nov 2007
Posts: 318 Brasil, Paraná
NeoNeper
OP
Senior Member
|
OP
Senior Member
Joined: Nov 2007
Posts: 318
Brasil, Paraná
|
Chaos, I'm pretty sure Neo wanted to automate the wait_for(), not have a callback function...
Exactly (^.^). Which, by the way, doesn't work. Nor does it need to, because wait_for() will always return immediately, since Neos DLL method will never ever be registered as still running in the engines Scheduler (no will it ever appear there as anything). No idea why he thought wait_for() is needed there, but it's definitely not.
I really did not know that. Thanks for clarifying. however, the lack of it generates crash in my functions, since sometimes the function attempts to validate variables that have not time to get a true value. below show an excerpt from my script that fails to validate a true value if I do not use a standby.
int results = sql_get_rows(); //DLL FUNCTION
wait_for(sql_get_rows); //the "wait" that I thought that would work
if(results)
{
...
}
If I remove the wait_for of the script, the "if(results)" may not receive a true value, because the function of the DLL may not havê had time to return a valid result. believe then that the most efficient way would be to use a simple "wait(1);". This is correct?
Please! Use easy words to be translated. because my English is not very good! Grateful. _______________________________________________________
|
|
|
Re: Questions about: How to create a macro function?
[Re: NeoNeper]
#431745
10/23/13 11:27
10/23/13 11:27
|
Joined: Oct 2011
Posts: 1,082 Germany
Ch40zzC0d3r
Serious User
|
Serious User
Joined: Oct 2011
Posts: 1,082
Germany
|
You should read my post again, I said something like that before. Just change the dll function or do it like this:
int iResults = -1;
iResults = sql_get_rows();
while(iResults == -1) wait(1);
if(iResults)
{
...
}
true == 1 false == 0 -1 should stay as long as the function didnt return ANYTHING.
Last edited by Ch40zzC0d3r; 10/23/13 11:56.
|
|
|
Re: Questions about: How to create a macro function?
[Re: Ch40zzC0d3r]
#431756
10/23/13 13:29
10/23/13 13:29
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
You both misunderstand the concept of "return". You cannot mix wait and return.
The first possibility is that sql_get_rows immediately returns a value. In this case iResults has a meaningful value and waiting may either happen forever (because sql_get_rows returned -1) or may not happen at all (because sql_get_rows returned something different).
The second possibility is that sql_get_rows does not return anything. In this case iResults is either random or remains at -1. I don't know. try it if you're interested.
Regardless of the possibilities described above iResults will never change afterwards so that the while loop is pointless.
Always learn from history, to be sure you make the same mistakes again...
|
|
|
|