Scolring - Forum

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.

#1 19-Nov-2010 00:57:32

kenshin1987
Member
Registered: 10-Nov-2010
Posts: 100

make a plugIt

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

#2 19-Nov-2010 01:02:03

kenshin1987
Member
Registered: 10-Nov-2010
Posts: 100

Re: make a plugIt

well ,I understand.
should be fun [u0]  [[S S] r1]

Kenshin

Offline

#3 19-Nov-2010 11:14:09

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,161
Website

Re: make a plugIt

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

#4 19-Nov-2010 12:07:58

kenshin1987
Member
Registered: 10-Nov-2010
Posts: 100

Re: make a plugIt

yes ,create my virtual school.

Offline

#5 19-Nov-2010 15:10:37

iri
Admin. / Scol language & Scol apps developer
From: France
Registered: 22-Feb-2009
Posts: 2,024
Website

Re: make a plugIt

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 :

mkfun console

Offline

#6 19-Nov-2010 17:18:16

kenshin1987
Member
Registered: 10-Nov-2010
Posts: 100

Re: make a plugIt

cool,thanks iri!

Offline

#7 19-Nov-2010 17:30:39

kenshin1987
Member
Registered: 10-Nov-2010
Posts: 100

Re: make a plugIt

but ,why there is a " a " behind 9?

Kenshin

Offline

#8 19-Nov-2010 18:31:21

iri
Admin. / Scol language & Scol apps developer
From: France
Registered: 22-Feb-2009
Posts: 2,024
Website

Re: make a plugIt

_fooI returns an hexadecimal number ! 10 -> a smile

_fooId returns a decimal number !

Offline

#9 19-Nov-2010 19:32:16

kenshin1987
Member
Registered: 10-Nov-2010
Posts: 100

Re: make a plugIt

I see,
thanks iri

Offline

#10 19-Nov-2010 22:06:14

iri
Admin. / Scol language & Scol apps developer
From: France
Registered: 22-Feb-2009
Posts: 2,024
Website

Re: make a plugIt

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

#11 19-Nov-2010 23:27:59

kenshin1987
Member
Registered: 10-Nov-2010
Posts: 100

Re: make a plugIt

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

#12 20-Nov-2010 00:32:43

iri
Admin. / Scol language & Scol apps developer
From: France
Registered: 22-Feb-2009
Posts: 2,024
Website

Re: make a plugIt

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

#13 20-Nov-2010 00:55:27

kenshin1987
Member
Registered: 10-Nov-2010
Posts: 100

Re: make a plugIt

I got it ,mkfunxxx  every time only consume one parameter.

Offline

#14 20-Nov-2010 11:46:28

iri
Admin. / Scol language & Scol apps developer
From: France
Registered: 22-Feb-2009
Posts: 2,024
Website

Re: make a plugIt

good !

Offline

Board footer

Powered by FluxBB