Project

General

Profile

Actions

Exceptions in Scol

exceptions are not yet explicitely supported.

However, you can use this method :

*_testpakS* is a Scol function. It loads a source string in the current environment without running and it returns nil if no error found or an explicit string message if an error occurs. But the program continue.

let _testpakS <string_code> -> result in
if result == nil then    // no error
    _loadS 
else
    // to do something
// continue

Something like that :

proto divideX = fun [] I;;

fun main ()=
    _showconsole;

    srand time;
    let (((rand&255)*100)>>8)-50 -> x in    // randomized value (-50 +50)
    let strcatn "fun divideX () = 100 / " :: (itoa x) :: ";;" :: nil -> strCode in
    let _testpakS strCode -> res in
    if (nil == res) then    // it's ok
    (
        _loadS strCode;    // we load and run this part of code
        _fooId divideX;
    )        
    else    // divide by zero !
    (
        _fooS res;
        _fooId x;
        1;
    );
    0;;

Depending on the context, you can also use the Scol functions *_testpak* or *_test_exist*.

License : CC-BY-SA-2.0
Tutorial by iri
Updated by /

Updated by iri about 12 years ago · 1 revisions