Reply to Custom procedures, return, script_used() etc.
If you don't have an account, just leave the password field blank.
I was experimenting with custom procedures and I have a few questions...
According to the DinkC reference (v3.1), external() creates a new instance of the script and using my_proc(); for example just calls that procedure in the same script. When playing around with this I noticed that while running a called procedure it counts as a seperate script (checked with script_used()). There's no difference if I use just my_proc() or external("cur_script", "my_proc"); .
IS this any different from external() when used for a proc. in the same script, and does it actually create another instance of the script (as it would seem, especially as local variables can't be referenced) or is it just the way script_used() works that makes it appear like that?
And does it make any difference?
return; - DinkC ref. v3.1 says this will exit the script but it actually exits the current procedure (as stated in DinkC ref. v4) rather than the whole script, is it wrong in v3.1 or have I not understood something?
v1.08 adds the ability to give and return values from procedures - what can be done with this? Not knowing any other languages other than DinkC I can't see a use for it... can someone give me an example of how this could be helpful?
If at all useful and/or interesting, here's the script I was using for procedure stuff:
//key-71.c (G)
void main (void)
{
say_xy("1", 0, 100);
wait(750);
test();
say_xy("4", 0, 250);
wait(750);
kill_this_task();
}
void test (void)
{
say_xy("2", 0, 150);
wait(750);
banana();
say_xy("3", 0, 200);
wait(750);
}
void banana (void)
{
say_xy("BANANA!!", 0, 300);
wait(750);
}
and I was testing it by tapping this:
//key-57.c (9)
void main (void)
{
int &cur_scrp = scripts_used();
say("There are &cur_scrp scripts being used right now.", 1);
kill_this_task();
}
which is key 9 in my Keys
According to the DinkC reference (v3.1), external() creates a new instance of the script and using my_proc(); for example just calls that procedure in the same script. When playing around with this I noticed that while running a called procedure it counts as a seperate script (checked with script_used()). There's no difference if I use just my_proc() or external("cur_script", "my_proc"); .
IS this any different from external() when used for a proc. in the same script, and does it actually create another instance of the script (as it would seem, especially as local variables can't be referenced) or is it just the way script_used() works that makes it appear like that?
And does it make any difference?
return; - DinkC ref. v3.1 says this will exit the script but it actually exits the current procedure (as stated in DinkC ref. v4) rather than the whole script, is it wrong in v3.1 or have I not understood something?
v1.08 adds the ability to give and return values from procedures - what can be done with this? Not knowing any other languages other than DinkC I can't see a use for it... can someone give me an example of how this could be helpful?
If at all useful and/or interesting, here's the script I was using for procedure stuff:
//key-71.c (G)
void main (void)
{
say_xy("1", 0, 100);
wait(750);
test();
say_xy("4", 0, 250);
wait(750);
kill_this_task();
}
void test (void)
{
say_xy("2", 0, 150);
wait(750);
banana();
say_xy("3", 0, 200);
wait(750);
}
void banana (void)
{
say_xy("BANANA!!", 0, 300);
wait(750);
}
and I was testing it by tapping this:
//key-57.c (9)
void main (void)
{
int &cur_scrp = scripts_used();
say("There are &cur_scrp scripts being used right now.", 1);
kill_this_task();
}
which is key 9 in my Keys







