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 28-Jan-2011 10:58:50

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

why can not wrote like this?

defcom maincom = main S I S;;
defcom CaddHistory = addHistory S;;

fun main(name,r,s)=
  // add the url in voyager history
  _on _masterchannel CaddHistory [name];

  _load "locked/lib/loc.pkg";
  _load "locked/stduser1.pkg";
  _script mkscript maincom [name r s];
0;;

why can not wrote like this?

defcom CaddHistory = addHistory S;;

fun main(name,r,s)=
  // add the url in voyager history
  _on _masterchannel CaddHistory [name];

  _load "locked/lib/loc.pkg";
  _load "locked/stduser1.pkg";
  main name r s;
0;;

EDIT iri : add <code> ...

Offline

#2 28-Jan-2011 14:27:20

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

Re: why can not wrote like this?

Hi Kenshin,

You can wrote this but you has missed a little thing.

- The Scol function : _load
It loads any local source code during the execution ! Not during the compilation time !
So, the main function is unknown yet, you must write its prototype before use it.

- First, verify the return of the load :

_fooI _load "locked/stduser1.pkg";

If success, _load returns 0. Launch the project and read the log : no value has been written. Why ? Because Scol stopped to the compilation, not the execution : stduser1.pkg hasn't been loaded, so no value returned.
- Then, it's normal that main is unknown ;-)

Your first code is ok, it's the same than the voyager.
Your second code should be :

defcom CaddHistory = addHistory S;;
proto main = fun [S I S] I;; // add the prototype before use the function

fun main_function (name,r,s)=
  // add the url in voyager history
  _on _masterchannel CaddHistory [name];

  _load "locked/lib/loc.pkg";
  _load "locked/stduser1.pkg";
  main name r s;
0;;

Now, it's ok.

Be carefull, you should change the name of the function. If you call with the same name, you risk a loop ... infinite ... infinite ! Here, i call it main_function.

Offline

Board footer

Powered by FluxBB