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
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
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
Pages: 1