Project

General

Profile

Scol standard library package  0.3.1
Common and usefull functions for all Scol applications
The packages API

Functions

 pkgs_pkgLoadCode (szCode, iFlag)
 Load a Scol code string in the current channel.
 pkgs_pkgLoadSafe (fPkg, iFlag)
 Load a package in the current channel.
 pkgs_pkgLoadSafeP (pPkg, iFlag)
 Load a package in the current channel.
 pkgs_pkgRemoveNLast (chn, n)
 Remove the N last loaded packages in a given channel.
 pkgs_pkgRemoveRecursive (chn, cbfun)
 Remove some last packages in a given channel to apply a callback.
 pkgs_pkgTest (pPkgName, cbfun)
 Test a package in the current channel next call a function.
 pkgs_pkgTestS (szCode, cbfun)
 Test a Scol code in the current channel next call a function.

Detailed Description

Package to load : lib/pkgs/pkg.pkg

Dependancies :

Function Documentation

pkgs_pkgRemoveNLast ( chn  ,
 
)

Remove the N last loaded packages in a given channel.

Remarks
These packages are not released in memory.

Prototype : fun [Chn I] I

Parameters
Chn: a channel (like _channel)
I: the number of packages to remove
Returns
I : 0 if success, other thing if an error occurs
pkgs_pkgRemoveRecursive ( chn  ,
cbfun   
)

Remove some last packages in a given channel to apply a callback.

Only if the callback returns 0, the recursion stops. Else, the recursion continues until all packages are removed.

Prototype : fun [Chn fun [Env S] I] I

Parameters
Chn: a channel (like _channel)
fun[Env S] I : the callback. It must return an integer (I). Its arguments are :
  • Env : the new environment (so, without the laready removed packages)
  • S : the last package name still loaded in this environment. If the environment is nil (all packages has been removed), this argument is nil too.
Returns
I : always the return of the callback.
pkgs_pkgTest ( pPkgName  ,
cbfun   
)

Test a package in the current channel next call a function.

Prototype : fun [P fun [I P S] u0] u0

Parameters
P: a read-file reference
fun[I P S] u0 : the function to call. Its arguments are :
  • I : 0 if no error, 2 if the file is invalid, incorrect or corrupted, else 1
  • P : the given read-file reference
  • S : the returned error or nil if no error
Returns
u0 : always the return of the called function.
pkgs_pkgTestS ( szCode  ,
cbfun   
)

Test a Scol code in the current channel next call a function.

Prototype : fun [S fun [I S S] u0] u0

Parameters
S: a code string
fun[I S S] u0 : the function to call. Its arguments are :
  • I : 0 if no error, else 1
  • S : the given code
  • S : the returned error or nil if no error
Returns
u0 : always the return of the called function.
pkgs_pkgLoadSafe ( fPkg  ,
iFlag   
)

Load a package in the current channel.

The loading can be safe : in this case, the package is checked before to be loaded.

Prototype : fun [S I] [I S]

Parameters
S: a filename of a package
I: a flag : PKGS_PKG_SAFE to have a safe loading, PKGS_PKG_UNSAFE (or any other value) to have an unsafe loading.
Returns
[I S] : a tuple :
  • I : 0 if success, other value else
  • S : always nil if success, the string error if error (only with PKGS_PKG_SAFE flag)
pkgs_pkgLoadSafeP ( pPkg  ,
iFlag   
)

Load a package in the current channel.

The loading can be safe : in this case, the package is checked before to be loaded.

Prototype : fun [P I] [I S]

Parameters
P: a read package reference
I: a flag : PKGS_PKG_SAFE to have a safe loading, PKGS_PKG_UNSAFE (or any other value) to have an unsafe loading.
Returns
[I S] : a tuple :
  • I : 0 if success, other value else
  • S : always nil if success, the string error if error (only with PKGS_PKG_SAFE flag)
pkgs_pkgLoadCode ( szCode  ,
iFlag   
)

Load a Scol code string in the current channel.

The loading can be safe : in this case, the code is checked before to be loaded.

Prototype : fun [S I] [I S]

Parameters
S: a Scol code
I: a flag : PKGS_PKG_SAFE to have a safe loading, PKGS_PKG_UNSAFE (or any other value) to have an unsafe loading.
Returns
[I S] : a tuple :
  • I : 0 if success, other value else
  • S : always nil if success, the string error if error (only with PKGS_PKG_SAFE flag)