Entraides et échanges autour de la technologie Scol - Informations and exchanges on the Scol technology
Vous pouvez changer la langue de l'interface une fois inscrit - You can change the language once registered
You are not logged in.
Pages: 1
Hi
/*! \brief Callback on plugIT instance editor closed
*
* <b>Prototype:</b> fun [] [[S S] r1]
*
* \return [[S S] r1] : parameters to save in the instance XML data
**/
fun cbCloseEdit(p)=
let p -> [ctrlint ctrlname] in
let getEdCtrlFloatValue ctrlint -> param1 in
let getEdCtrlTextLineValue ctrlname -> param2 in
["param1" ftoa param1]::
["param2" param2]::
nil;;
I can not understand ,the Prototype say fun [] (no parameter).
but cbCloseEdit(p) has a parameter p...
Offline
well ,I understand.
should be fun [u0] [[S S] r1]
Kenshin
Offline
hi kenshin
in scol a prototype can be modified when calling the function with mkfun1, mkfun2, mkfun3 ....
it's explain in the Scol language documentation
great to see that you seems to understand scol pretty good.
do you learn scol for a student project ?
Offline
yes ,create my virtual school.
Offline
Hi Kenshin1987,
mkfunX add an argument to any function.
(X range 1, 8)
mkfunX my_function mkfunX_parameter
It's possible to put several mkfunX
mkfunX mkfunY my_function mkfunY_parameter mkfunX_parameter
Be carefull ! Parameter order is reversed !
Here, a basic (and stupid !) example :
It is a simple counter (note that you can code it differently but it is a stupid example !)
var count = 0;;
/* "Normal" type would be it : fun [ObjTimer u0] u1
here, we have it : fun [ObjTimer u3 u4 u0] u1 */
fun callbackTimer (timer, mkfun3_param, mkfun4_param, user_param)=
set count = count + user_param;
if (count > mkfun3_param) then
(
_fooS mkfun4_param;
_deltimer timer;
0;
)
else
_fooI count;;
fun main ()=
_showconsole;
_rfltimer /* define the callback of the timer */
_starttimer /* create a timer with a period de 1000 ms */
_channel
1000
mkfun3 /* add a third argument to the callback = count max */
mkfun4 /* add a fourth argument to the callback = finished message */
@callbackTimer /* callback function name */
1 /* classic user parameter */
"Finished !" /* fourth value of the callback (mkfun4) */
10; /* third value of the callback (mkfun3) */
0;;
The result :
Offline
cool,thanks iri!
Offline
but ,why there is a " a " behind 9?
Kenshin
Offline
I see,
thanks iri
Offline
I forgot ...
- You can find mknode. It is an alias : mkfun1
- In my example, callbackTimer take two orguments. So, to add a third, you must use mkfun3, to add a fourth, mkfun4, etc
If a function take one argument, you start at mkfun2, etc ...
Offline
like this:
var count = 0;;
/* "Normal" type would be it : fun [ObjTimer u0] u1
here, we have it : fun [ObjTimer u3 u4 u0] u1 */
fun callbackTimer (timer, mkfun3_param, mkfun4_param, user_param)=
set count = count + user_param;
if (count > mkfun3_param) then
(
_fooS mkfun4_param;
_deltimer timer;
0;
)
else
_fooI count;;
fun main ()=
_showconsole;
_rfltimer /* define the callback of the timer */
_starttimer /* create a timer with a period de 1000 ms */
_channel
1000
mkfun2 /* add a third argument to the callback = count max */
@callbackTimer /* callback function name */
"Finished !"
1
10;
0;;
right?
Last edited by kenshin1987 (19-Nov-2010 23:30:11)
Offline
No.
Look at the doc : _rfltimer
The callback must take two arguments ( fun [Timer u0] u1 ) :
- the timer object;
- the user parameter (at your convenience).
In Scol package :
_rfltimer timer callback_name user_parameter
By example :
Typeof timer = Timer;;
...
set timer = _starttimer _channel 1000;
_rfltimer timer @callbackTimer 1;
...
All right.
If you want add an argument, you must begin at 3 : timer object (1st), user parameter (2nd), your added parameter (3rd -> mkfun3).
Next, in your package, you have :
the timer (_starttiler _channel 1000)
the callback definition :
_rfltimer timer mkfun3 @callbackTimer user_parameter your_added_parameter
After the name of the callback, you have the classic user parameter. And next, your added parameter with mkfun3.
So, your main function should be :
fun main ()=
_showconsole;
_rfltimer
_starttimer
_channel
1000
mkfun3 /* <-------- mkfun3, not mkfun2 */
@callbackTimer
"Finished !" /* <------- user parameter */
1 /* <-------- your third parameter (mkfun 3) */
/* 10; */ /* <------- No ! you have THIRD argument, not FOUR (timer object is implicit) where is mkfun4 ? */
0;;
Next, your callback function is incorrect : there are 4 arguments and you define 3 arguments in the main. "mkfun4_param" must be removed.
To add a fourth argument, you add "mkfun4" AFTER "mkfun3" and you set its value BEFORE mkfun3's value (symetric with (callback_name+user_parameter)) !
_rfltimer timer mkfun3 mkfun4 @function_name user_parameter mkfun4_parameter mkfun3_parameter
And in your function :
fun callback_function (timer, mkfun3_parameter, mkfun4 parameter, user_parameter)=
...
IF you have define FOUR arguments in your main
If 3 arguments only :
fun callback_function (timer, mkfun3_parameter, user_parameter)=
...
Help :
The Scol language tutorial, 2000 or 2001 by Sylvain Huet (in English) but the bases are ok.
I wrote some tutorials, to begin with Scol. Unlikely, they are in French. Maybe you can translate them automatically (by any web service) ? If any, they are here.
Otherwise, there is the forum !
iri
Offline
I got it ,mkfunxxx every time only consume one parameter.
Offline
Pages: 1