Goto main content

package

Define a package in sncode

PACKAGE

NAME

package - Define a package in sncode

SYNOPSIS

package name; ... endp;

DESCRIPTION

A package can be used to defined function in a differente namespace.

Starting with sncode 5.42, variables can also be defined for the package.

To access a function with  a package, the following syntax is used:

package_name :: function_name(...);

To access a variable with a package, the following syntax is used:

package_name :: variable 

Inside a package, you don,t have to put the package_name except in a function as in:

package test;

    config = 5;

    function f()

        "config="; test::config;

    endf

endp

It is possible to omit the package name for a variable. In that case, the variable is in a namespace of its own

and can be used as is a package name was specify as in:

package a;
::config = { "sql" : "select username from sn_users" };
function f()
res = sql(::config.sql);
::config.res = res.rows[0];
endf
endp
a::f();
::config.res.username;

EXAMPLES

package a;

            config = { "sql" : "select username from sn_users" };

            function f()

                res = sql(a::config.sql);

                a::config.res = res.rows[0];

            endf
endp


a::f();

a::config.res.username;

 

SEE ALSO

AUTHOR

Written by Pierre Laplante, <laplante@sednove.com>

MODIFICATIONS

1.0 2016-02-03 21:24:14 laplante@sednove.com

Edit

© 2024 extenso Inc. All rights reserved.