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 21-Sep-2014 01:12:59

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,541
Website

Problem understanding editor plugit file

colleagues:

I am trying to simplify the text input/output client file I have been working on. Since it doesn't need a checkbox control, I tried to leave it out, but I'm doing something wrong in changing:

// prototype of the cbCloseEdit function in case you don't use params

//proto cbCloseEdit = fun [] [[S S] r1];;



// Close callback called on apply / Ok button, this callback return the parameters to save in the XOS project

fun cbCloseEdit(ctrlinit)=

  // get the check state and add it to the param list

  let itoa getEdCtrlCheckState ctrlinit -> state in

    ["oninit" state]::

    nil;;





// Destroy callback called when the editor window is destroyed, this is useful to destroy added objects or resources

fun cbDestroyEdit()=

  0;;





// Init function called when a user the plugIT Editor

fun dynamicedit(winstr, inst, viewstr) =

  // size of the window

  let [400 90] -> [iw ih] in

  (

    // resize the editor window

    setEdWindowSize winstr iw ih;



    // retrieve the current param value

    let atoi (getPluginInstanceParam inst "oninit") -> state in

    

    // create the check box control on the editor window

    let crEdCtrlCheck winstr 10 10 280 20 "Run on init" EDWIN_RESIZE_MW -> ctrlinit in

    (

      // set the current check state

      setEdCtrlCheckState ctrlinit state;



      [(mkfun1 @cbCloseEdit ctrlinit) @cbDestroyEdit];

    );

  );;

to

// prototype of the cbCloseEdit function in case you don't use params

//proto cbCloseEdit = fun [] [[S S] r1];;



// Close callback called on apply / Ok button, this callback return the parameters to save in the XOS project

fun cbCloseEdit()=

    0;;





// Destroy callback called when the editor window is destroyed, this is useful to destroy added objects or resources

fun cbDestroyEdit()=

  0;;





// Init function called when a user the plugIT Editor

fun dynamicedit(winstr, inst, viewstr) =

  // size of the window

  let [400 90] -> [iw ih] in

  (

    // resize the editor window

    setEdWindowSize winstr iw ih;

      [(mkfun1 @cbCloseEdit nil) @cbDestroyEdit];

  );
  0;;

in particulart, I don't understand the meaning of this line:

      [(mkfun1 @cbCloseEdit ctrlinit) @cbDestroyEdit];

since that is where the error is arising:

> Error : PlugIT chatwindow in file :tools/os3dplugins/misc/chatwindow/echatwindow.pkg
File : C:\Program Files (x86)\Scol Voyager\Partition_LockedApp\tools\os3dplugins\misc\chatwindow\echatwindow.pkg
(!) Line #21:
      [(mkfun1 @cbCloseEdit nil??) @cbDestroyEdit];

syntax error
>>> ERROR - Type mismatch (detail):
Found:    [fun [] I u0]
Expected: [fun [u0] u1 u0]

thanks!
I plan on improving the editor interface for the plugit I coded, with the aim of understanding it.

-h

Last edited by hebdemnobad (21-Sep-2014 01:14:08)

Offline

#2 21-Sep-2014 11:17:14

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

Re: Problem understanding editor plugit file

hebdemnobad wrote:
      [(mkfun1 @cbCloseEdit ctrlinit) @cbDestroyEdit];

since that is where the error is arising:

> Error : PlugIT chatwindow in file :tools/os3dplugins/misc/chatwindow/echatwindow.pkg
File : C:\Program Files (x86)\Scol Voyager\Partition_LockedApp\tools\os3dplugins\misc\chatwindow\echatwindow.pkg
(!) Line #21:
      [(mkfun1 @cbCloseEdit nil??) @cbDestroyEdit];

syntax error
>>> ERROR - Type mismatch (detail):
Found:    [fun [] I u0]
Expected: [fun [u0] u1 u0]

thanks!
I plan on improving the editor interface for the plugit I coded, with the aim of understanding it.

-h


To do simple, in Scol, you can add one or more arguments in a function.
By example, imagine a function like :

fun foo ()=
  // something

When you call it, you do :

foo;

Now, imagine, for any reason, you need more arguments : then you use mkfunX function (these are a Scol function).

So, in OS3D, cbCloseEdit is set as fun [ ] [[S S] r1];;
e.g. no argument (fun [ ]). This is its initial prototype when OS3D is loaded. Right ?

To obtain a ctrlinit structure argument in this function, we must "update" its prototype from fun [ ] [[S S] r1] to fun [u0] [[S S] r1] AFTER the os3d loading.
u0 will be our ctrlinit argument.

This update is done by mkfun1 function : mkfun1 add an argument to a function with no argument (mkfun2, mkfun3, .... exist too and it is possible to combine several mkfunX in the same update) :

fun cbCloseEdit(ctrlinit)=  // one argument added (ctrlinit)
  // something

fun dynamicedit(winstr, inst, viewstr) =
  // ...
  [(mkfun1 @cbCloseEdit ctrlinit) @cbDestroyEdit];  // prototype updated for cbCloseEdit


In your code, you needn't this supplemental argument. Ok, in this case, you nedn't mkfun1 function !

So your code should be :

fun cbCloseEdit()=  // no argument added
  // something

fun dynamicedit(winstr, inst, viewstr) =
  // ...
  [@cbCloseEdit  @cbDestroyEdit];  // initial/normal prototype

You use the original proptotype of cbCloseEdit !


If you want keep this update (because you think add some controls in the window in the future), keep the argument in cbCloseEdit !

fun cbCloseEdit(ctrlinit)=
    nil;;

fun dynamicedit(winstr, inst, viewstr) =
  // size of the window
  let [400 90] -> [iw ih] in
  (
    // resize the editor window
    setEdWindowSize winstr iw ih;
    [(mkfun1 @cbCloseEdit nil) @cbDestroyEdit];
    0
  );;

Offline

#3 21-Sep-2014 14:01:38

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,541
Website

Re: Problem understanding editor plugit file

I changed the final function to:

fun dynamicedit(winstr, inst, viewstr) =

  // size of the window

  let [400 90] -> [iw ih] in

  (

    // resize the editor window

    setEdWindowSize winstr iw ih;

    [@cbCloseEdit  @cbDestroyEdit];
    0 

  );;

so I tried ending the internal code in the let ->... braces with
and still got the error connected with that function:

File : C:\Program Files (x86)\Scol Voyager\Partition_LockedApp\tools\os3dplugins\misc\chatwindow\echatwindow.pkg
(!) Line #23:
  )??;;
syntax error
>>> ERROR - Type mismatch (detail):
Found:    fun [EdWindow PInstance V3Dview] [fun [] [[S S] r1] fun [] I]
Expected: fun [EdWindow PInstance V3Dview] I
<<<


> Error : PlugIT chatwindow : misc/chatwindow/chatwindow.xml can not be found.
> All plugITs reloaded.

so I tried:

(!) Line #23:
  )??;;
syntax error
>>> ERROR - Type mismatch (detail):
Found:    fun [EdWindow PInstance V3Dview] [fun [] [[S S] r1] fun [] I]
Expected: fun [EdWindow PInstance V3Dview] I
<<<


> Error : PlugIT chatwindow : misc/chatwindow/chatwindow.xml can not be found.
> All plugITs reloaded.

and got this:

(!) Line #23:
  )??;;
syntax error
>>> ERROR - Type mismatch (detail):
Found:    fun [EdWindow PInstance V3Dview] [fun [] [[S S] r1] fun [] I]
Expected: fun [EdWindow PInstance V3Dview] I
<<<


> Error : PlugIT chatwindow : misc/chatwindow/chatwindow.xml can not be found.
> All plugITs reloaded.

so I tried:

fun dynamicedit(winstr, inst, viewstr) =

  // size of the window

  let [400 90] -> [iw ih] in

  (

    // resize the editor window

    setEdWindowSize winstr iw ih;

    [@cbCloseEdit  @cbDestroyEdit];
    0

  );;

and I got:

(!) Line #23:
  )??;;
syntax error
>>> ERROR - Type mismatch (detail):
Found:    fun [EdWindow PInstance V3Dview] [fun [] [[S S] r1] fun [] I]
Expected: fun [EdWindow PInstance V3Dview] I
<<<

so I tried:

fun dynamicedit(winstr, inst, viewstr) =

  // size of the window

  let [400 90] -> [iw ih] in

  (

    // resize the editor window

    setEdWindowSize winstr iw ih;

    [@cbCloseEdit  @cbDestroyEdit];
    0;

  );;

and I got:

(!) Line #23:
  )??;;
syntax error
>>> ERROR - Type mismatch (detail):
Found:    fun [EdWindow PInstance V3Dview] [fun [] [[S S] r1] fun [] I]
Expected: fun [EdWindow PInstance V3Dview] I
<<<


> Error : PlugIT chatwindow : misc/chatwindow/chatwindow.xml can not be found.
> All plugITs reloaded.

so I tried:

fun dynamicedit(winstr, inst, viewstr) =

  // size of the window

  let [400 90] -> [iw ih] in

  (

    // resize the editor window

    setEdWindowSize winstr iw ih;

    [@cbCloseEdit  @cbDestroyEdit];
    0;

  );
  0;;

and got:

(!) Line #24:
  0??;;
syntax error
>>> ERROR - Type mismatch (detail):
Found:    fun [EdWindow PInstance V3Dview] [fun [] [[S S] r1] fun [] I]
Expected: fun [EdWindow PInstance V3Dview] I
<<<


> Error : PlugIT chatwindow : misc/chatwindow/chatwindow.xml can not be found.
> All plugITs reloaded.

So I'm getting the same error code probably here based on the prototype for

@cbCloseEdit

Offline

#4 21-Sep-2014 14:08:31

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

Re: Problem understanding editor plugit file

Sorry, i pasted the previous code.
Remove the last 0 and enjoy !


fun dynamicedit(winstr, inst, viewstr) =
  // size of the window
  let [400 90] -> [iw ih] in
  (
    // resize the editor window
    setEdWindowSize winstr iw ih;
    [@cbCloseEdit  @cbDestroyEdit];
  );;

dynamicedit must return a tuple with the close and destroy callbacks. Not an integer.

Offline

#5 21-Sep-2014 14:10:23

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

Re: Problem understanding editor plugit file

or

fun dynamicedit(winstr, inst, viewstr) =
  // size of the window
  let [400 90] -> [iw ih] in
  (
    // resize the editor window
    setEdWindowSize winstr iw ih;
    [mkfun1 @cbCloseEdit nil  @cbDestroyEdit];
  );;

If you want keep an argument for the close callback.

Offline

#6 21-Sep-2014 14:10:46

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,541
Website

Re: Problem understanding editor plugit file

and I tried:

// prototype of the cbCloseEdit function in case you don't use params

//proto cbCloseEdit = fun [] [[S S] r1];;



// Close callback called on apply / Ok button, this callback return the parameters to save in the XOS project

fun cbCloseEdit(argument)=

    0;;





// Destroy callback called when the editor window is destroyed, this is useful to destroy added objects or resources

fun cbDestroyEdit()=

  0;;





// Init function called when a user the plugIT Editor

fun dynamicedit(winstr, inst, viewstr) =
  // size of the window
  let [400 90] -> [iw ih] in
  (
    // resize the editor window
    setEdWindowSize winstr iw ih;
    [(mkfun1 @cbCloseEdit nil) @cbDestroyEdit];
    0
  );;

and got this:

(!) Line #23:
  )??;;
syntax error
>>> ERROR - Type mismatch (detail):
Found:    fun [EdWindow PInstance V3Dview] [fun [] [[S S] r1] fun [] I]
Expected: fun [EdWindow PInstance V3Dview] I
<<<


> Error : PlugIT chatwindow : misc/chatwindow/chatwindow.xml can not be found.
> All plugITs reloaded.

so I tried:

// prototype of the cbCloseEdit function in case you don't use params

//proto cbCloseEdit = fun [] [[S S] r1];;



// Close callback called on apply / Ok button, this callback return the parameters to save in the XOS project

fun cbCloseEdit(argument)=

    0;;





// Destroy callback called when the editor window is destroyed, this is useful to destroy added objects or resources

fun cbDestroyEdit()=

  0;;





// Init function called when a user the plugIT Editor

fun dynamicedit(winstr, inst, viewstr) =
  // size of the window
  let [400 90] -> [iw ih] in
  (
    // resize the editor window
    setEdWindowSize winstr iw ih;
    [(mkfun1 @cbCloseEdit nil) @cbDestroyEdit];
    0;
  );;

and got this

(!) Line #23:
  )??;;
syntax error
>>> ERROR - Type mismatch (detail):
Found:    fun [EdWindow PInstance V3Dview] [fun [] [[S S] r1] fun [] I]
Expected: fun [EdWindow PInstance V3Dview] I
<<<


> Error : PlugIT chatwindow : misc/chatwindow/chatwindow.xml can not be found.
> All plugITs reloaded.

Aside from the problem I am encountering, I'm still wondering about that line:

    [(mkfun1 @cbCloseEdit nil) @cbDestroyEdit];

in all the times I define a callback in the client file, I put it in a statement that has the plugit registering an action, or an event that happens to a comptext control, or an event that happens when the client plugit is destroyed, but in this statement in the editor file, I just specify two callbacks, so what exactly is happening?

perhaps my question is not phrased that well, but I haven't ventured into writing and tinkering with an editor file before.

Offline

#7 21-Sep-2014 14:13:52

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,541
Website

Re: Problem understanding editor plugit file

iri wrote:

or

fun dynamicedit(winstr, inst, viewstr) =
  // size of the window
  let [400 90] -> [iw ih] in
  (
    // resize the editor window
    setEdWindowSize winstr iw ih;
    [mkfun1 @cbCloseEdit nil  @cbDestroyEdit];
  );;

If you want keep an argument for the close callback.


I think I tried this but I forgot, so I did it again and put it in the plugins folder:

// prototype of the cbCloseEdit function in case you don't use params

//proto cbCloseEdit = fun [] [[S S] r1];;



// Close callback called on apply / Ok button, this callback return the parameters to save in the XOS project

fun cbCloseEdit(argument)=

    0;;





// Destroy callback called when the editor window is destroyed, this is useful to destroy added objects or resources

fun cbDestroyEdit()=

  0;;





// Init function called when a user the plugIT Editor

fun dynamicedit(winstr, inst, viewstr) =
  // size of the window
  let [400 90] -> [iw ih] in
  (
    // resize the editor window
    setEdWindowSize winstr iw ih;
    [mkfun1 @cbCloseEdit nil  @cbDestroyEdit];
  );;

and still got that error arrgggg!

(!) Line #22:
  )??;;
syntax error
>>> ERROR - Type mismatch (detail):
Found:    fun [EdWindow PInstance V3Dview] [fun [] [[S S] r1] fun [] I]
Expected: fun [EdWindow PInstance V3Dview] [fun [] I fun [] I]
<<<


> Error : PlugIT chatwindow : misc/chatwindow/chatwindow.xml can not be found.
> All plugITs reloaded.

Offline

#8 21-Sep-2014 14:25:51

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

Re: Problem understanding editor plugit file

With the initial or updated prototype, the close callback (in the os3d editor gui !!) must return a list of tuple :

[[S S] r1]

So, you should write :

fun cbCloseEdit(argument)=
    nil;;

It might be necessary to add an explicit prototype BEFORE the function (depending as the os3d code is written) :

with the initial prototype

proto cbCloseEdit = fun [] [[S S] r1];;

fun cbCloseEdit ()=
    nil;;

with the updated prototype

proto cbCloseEdit = fun [u0] [[S S] r1];;

fun cbCloseEdit (argument)=
    nil;;

Offline

#9 21-Sep-2014 14:39:24

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,541
Website

Re: Problem understanding editor plugit file

it works it works! so it was the cbCloseEdit function, scol didn't like 0 as a return value but did like nil!
thanks as always Iri....I still don't understand an error like
Found:    fun [u0] [[S S] r1]
Expected: fun [u0] I

what makes cbCloseEdit(argument)  take the form of
Found:    fun [u0] [[S S] r1]?

I assume u0 is an unknown argument added by the mkfun1 statement.  what are those 2 string values related to? why does scol add r1 if those two string values are not repeated more than once?

answer at your leisure, I think I can continue in my somewhat ignorant coding.
-h

Offline

#10 21-Sep-2014 15:42:00

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

Re: Problem understanding editor plugit file

hebdemnobad wrote:

so it was the cbCloseEdit function, scol didn't like 0 as a return value but did like nil!

A lot of function return an integer like 0. But not this function !

hebdemnobad wrote:

I still don't understand an error like
Found:    fun [u0] [[S S] r1]
Expected: fun [u0] I

Rhoo, it is a bug,
found type and expected type has been reversed. This is already fixed in the next Scol release.

So, the right error is :

Expected:    fun [u0] [[S S] r1]
Found: fun [u0] I
hebdemnobad wrote:

what makes cbCloseEdit(argument)

In os3d, dynamicedit is defined as :

proto dynamicedit = fun [EdWindow PInstance V3Dview] [fun [] [[S S] r1] fun [] I];;

So :
fun [EdWindow PInstance V3Dview] = 3 arguments
its return is :
[fun [] [[S S] r1] fun [] I] = a tuple.
- the first element is the close prototype (fun [] [[S S] r1])
- the second element is the destroy prototype. (fun [] I)

What make the close function :
the close function save the plugit setting in the project file.
This save is done "automatically" but the values must be given : these two string : a key, a value.
For example : a key like "oninit" and a value like "1" (or "0" ...)

Depending the plugIt, no, one or several parameters can be saved. So, the return must be a list.

No parameter, the close function returns a simple nil.
One parameter : the close function returns ["a_key" "a_value"] :: nil
Several parameters : the close function returns : ["key1" "value1"] ::  ["key2" "value2"] ::  ["key3" "value3"] ::  ["key4" "value4"] ::  ... :: nil

A list is generic.
Otherwise, a saving function must be written to each plugit.

hebdemnobad wrote:

why does scol add r1

Because the recursion of the list is level 1. The level 1 is the most common. The level 2 is rarer. The level 3 and more are theoretical and i never use it.
A level 1 points out that each element are the same type (here [S S] : a tuple with two strings, so all element must be in this type)

Offline

#11 21-Sep-2014 21:19:07

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,541
Website

Re: Problem understanding editor plugit file

so dynamicedit returns two functions, the first returned function cbclosedit in turn returns tuples (of two  strings per tuple) of arbitrary length (2 for each parameter passed to cbslosedit), and the second returned function cbdestroy returns an interger.

so if I have to pass 180 parameters to cbclosedit, it will return 180 tuples, each tuple made up of two strings, each tuple per parameter I wish to save (180 in this example)

I think I kind of understand it.

So let's say I want to allow a user to set the width and height of the input/output text window using the editor....what would I have to add to the .xml file and editor file? (This is different than the template plugit since I'm not creating a check box but a couple of boxes to enter integers.)

Respond at your leisure. (I'm recovering from a cold today and tire easily.)
I didn't know that dynamicedit was a reserved word in os3d, I thought it was an arbitrary name.

Offline

#12 21-Sep-2014 23:32:14

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

Re: Problem understanding editor plugit file

hebdemnobad wrote:

so dynamicedit returns two functions

NO !! A function always returns one value only.

Here, this value is a tuple. The size of this tuple is 2 (it contains two elements).

The first element defines the callback when the editor is closed. This callback must return a list of two strings tuples.
The second element defines the callback when the editor is destroyed. This callback must return an integer.

hebdemnobad wrote:

so if I have to pass 180 parameters to cbclosedit, it will return 180 tuples, each tuple made up of two strings, each tuple per parameter I wish to save (180 in this example)

Yes, a list. The size of this list will be 180.

hebdemnobad wrote:

So let's say I want to allow a user to set the width and height of the input/output text window using the editor

Read the dynamicedit function in an editor with an edit text box to see the code. It's not difficult. OS3d features an API for that.

hebdemnobad wrote:

I didn't know that dynamicedit was a reserved word in os3d, I thought it was an arbitrary name.

It is an arbitrary name in Scol.
It is a reserved word in os3d only. It is defined in os3dlib/os3dpreplug.pkg

Offline

#13 21-Sep-2014 23:34:41

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

Re: Problem understanding editor plugit file

hebdemnobad wrote:

so dynamicedit returns two functions

NO !! A function always returns one value only.

Here, this value is a tuple. The size of this tuple is 2 (it contains two elements).

The first element defines the callback when the editor is closed. This callback must return a list of two strings tuples.
The second element defines the callback when the editor is destroyed. This callback must return an integer.

hebdemnobad wrote:

so if I have to pass 180 parameters to cbclosedit, it will return 180 tuples, each tuple made up of two strings, each tuple per parameter I wish to save (180 in this example)

Yes, a list. The size of this list will be 180.

hebdemnobad wrote:

So let's say I want to allow a user to set the width and height of the input/output text window using the editor

Read the dynamicedit function in an editor with an edit text box to see the code. It's not difficult. OS3d features an API for that.

hebdemnobad wrote:

I didn't know that dynamicedit was a reserved word in os3d, I thought it was an arbitrary name.

It is an arbitrary name in Scol.
It is a reserved word in os3d only. Like any function name already loaded by an Scol application. It is defined in os3dlib/os3dpreplug.pkg

Offline

#14 22-Sep-2014 01:24:15

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,541
Website

Re: Problem understanding editor plugit file

Thx Iri I'll try making a couple of controls to set the window width/height.

Offline

Board footer

Powered by FluxBB