One more time fighting with scripting, i don't understand how to wait x blocs or x ms before processing a new function or a new procedure in script...
I've been looking to midi unpack, to unpack array but i've not been able to reproduce them in my newbie scripts...
Any help from a script master?
[script] Wait x blocs or ms
The clou to this is counting (for n blocks) or checking elapsed time (for ms), and when queueing data like in the two mentioned scripts, adding and retrieving data from the queue.
The last part is IMO the most complicated and can be handled several ways, but since you mentioned waiting with processing a method, I'll stick to that.
What you have to do is initialize some variable when the waiting starts - usually by something triggering a callback, eg:
[c]
VAR countWaits : Integer;
VAR startTime : Single;
VAR doUpdate : Boolean;
....
PROCEDURE Callback(n : Integer);
...
<some_callback>
countWaits := 0;
startTime := timeMs;
doUpdate := TRUE;
...
[/c]
Then you have to check within Process whether it's about time to do something:
[c]
PROCEDURE Process;
...
IF (doUpdate) THEN BEGIN
countWaits := countWaits + 1;
IF (countWaits >= no_of_waits) THEN BEGIN
do_something;
doUpdate := FALSE;
...
IF (doUpdate) THEN BEGIN
IF ((timeMs - startTime) >= time_to_wait) THEN BEGIN
do_something;
doUpdate := FALSE;
...
[/c]
When queueing data, you wouldn't normally have any use for something like the doUpdate boolean, but instead you'd be checking whether there was anything left in the queue to handled.
Hope this helps.
The last part is IMO the most complicated and can be handled several ways, but since you mentioned waiting with processing a method, I'll stick to that.
What you have to do is initialize some variable when the waiting starts - usually by something triggering a callback, eg:
[c]
VAR countWaits : Integer;
VAR startTime : Single;
VAR doUpdate : Boolean;
....
PROCEDURE Callback(n : Integer);
...
<some_callback>
countWaits := 0;
startTime := timeMs;
doUpdate := TRUE;
...
[/c]
Then you have to check within Process whether it's about time to do something:
[c]
PROCEDURE Process;
...
IF (doUpdate) THEN BEGIN
countWaits := countWaits + 1;
IF (countWaits >= no_of_waits) THEN BEGIN
do_something;
doUpdate := FALSE;
...
IF (doUpdate) THEN BEGIN
IF ((timeMs - startTime) >= time_to_wait) THEN BEGIN
do_something;
doUpdate := FALSE;
...
[/c]
When queueing data, you wouldn't normally have any use for something like the doUpdate boolean, but instead you'd be checking whether there was anything left in the queue to handled.
Hope this helps.
Bjørn S
Thanks master Bsork!
Trying that right now...
Trying that right now...
Seb.Dub
I have not been able to do the script i need....
Anyway, i found a way to patch it:

This scripting technique is yet to difficult for the moment. I need to study more the use of array in scripts.
Thanks for your help ,time, and knowledge Bsork.
Anyway, i found a way to patch it:

This scripting technique is yet to difficult for the moment. I need to study more the use of array in scripts.
Thanks for your help ,time, and knowledge Bsork.
Seb.Dub
Who is online
Users browsing this forum: No registered users and 75 guests
