开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (1)
master
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
项目仓库所选许可证以仓库主分支所使用许可证为准
master
分支 (1)
master
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (1)
master
module.html 7.84 KB
一键复制 编辑 原始数据 按行查看 历史
麦壳饼 提交于 2016年07月26日 10:47 +08:00 . chuci tijiao
<html><head><title>Module</title></head>
<body bgcolor="#FFFFFF" link="#207BC3" vlink="#003B83" alink="#003B83">
<font face="Arial" size="2"><p align="center"><b><font size="5">Module</font></b></p>
<br><b>Syntax</b><blockquote><pre><font face="Courier New, Courier, mono"size="2"><b><font color="#207BC3">DeclareModule</font></b> &lt;name&gt;
...
<b><font color="#207BC3">EndDeclareModule</font></b>
<b><font color="#207BC3">Module</font></b> &lt;name&gt;
...
<b><font color="#207BC3">EndModule</font></b>
<b><font color="#207BC3">UseModule</font></b> &lt;name&gt;
<b><font color="#207BC3">UnuseModule</font></b> &lt;name&gt;
</font></pre></blockquote>
<b>Description</b><br><blockquote>
Modules are an easy way to isolate code part from the main code, allowing code reuse and sharing
without risk of name conflict. In some other programming languages, modules are known as 'namespaces'.
A module must have a <b><font color="#207BC3">DeclareModule</font></b> section (which is the public interface) and an associated
<b><font color="#207BC3">Module</font></b> section (which is the implementation).
Only items declared in the <b><font color="#207BC3">DeclareModule</font></b> section will be accessible from outside the module. All the
code put in the <b><font color="#207BC3">Module</font></b> section will be kept private to this module. Items from main code
like procedures, variables etc. won't be accessible inside the module, even if they are <a href="global.html">global</a>. A module can be seen
as a blackbox, an empty code sheet where item names can not conflict with the main code. It makes it easier
to write specific code, as simple names can be reused within each module without risk of conflict.
<br>
<br>
Items allowed in the <b><font color="#207BC3">DeclareModule</font></b> section can be the following: procedure (only procedure declaration allowed), structure, macro, variable,
constant, enumeration, array, list, map and label.
<br>
<br>
To access a module item from outside the module, the module name has to be specified followed by the '::' separator. When explicitly specifying
the module name, the module item is available everywhere in the code source, even in another module.
All items in the <b><font color="#207BC3">DeclareModule</font></b> section can be automatically imported into another module or in the main code using <b><font color="#207BC3">UseModule</font></b>.
In this case, if a module name conflict, the module items won't be imported and a compiler error will be raised.
<b><font color="#207BC3">UnuseModule</font></b> remove the module items. <b><font color="#207BC3">UseModule</font></b> is not mandatory to access a module item, but the module name needs to be specified.
<br>
<br>
To share information between modules, a common module can be created and then used in every modules which needs it. It's the common way
have global data available for all modules.
<br>
<br>
Default items available in modules are all SpiderBasic commands, structure and constants. Therefore module items can not be named like
internal SpiderBasic commands, structure or constants.
<br>
<br>
All code put inside <b><font color="#207BC3">DeclareModule</font></b> and <b><font color="#207BC3">Module</font></b> sections is executed like any other code when the program flow reaches the module.
<br>
<br>
When the statements <b><font color="#207BC3">Define</font></b>, <b><font color="#207BC3">EnableExplicit</font></b>, <b><font color="#207BC3">EnableASM</font></b> are used inside a module, they have no effect outside the respective module, and vice versa.
<br>
<br>
Note: modules are not mandatory in SpiderBasic but are recommended when building big projects. They help to build more maintainable
code, even if it is slightly more verbose than module-free code. Having a <b><font color="#207BC3">DeclareModule</font></b> section make the module pretty much self-documented
for use when reusing and sharing it.
</blockquote><p><b>Example</b></p><blockquote>
<pre><font face="Courier New, Courier, mono"size="2">
<font color="#207BC3">; Every items in this sections will be available from outside</font>
<font color="#207BC3">;</font>
<b><font color="#207BC3">DeclareModule</font></b> Ferrari
<font color="#924B72">#FerrariName$</font> = &quot;458 Italia&quot;
<b><font color="#207BC3">Declare</font></b> <font color="#207BC3">CreateFerrari</font>()
<b><font color="#207BC3">EndDeclareModule</font></b>
<font color="#207BC3">; Every items in this sections will be private. Every names can be used without conflict</font>
<font color="#207BC3">;</font>
<b><font color="#207BC3">Module</font></b> Ferrari
<b><font color="#207BC3">Global</font></b> Initialized = <font color="#924B72">#False</font>
<b><font color="#207BC3">Procedure</font></b> <font color="#207BC3">Init</font>() <font color="#207BC3">; Private init procedure</font>
<b><font color="#207BC3">If</font></b> Initialized = <font color="#924B72">#False</font>
Initialized = <font color="#924B72">#True</font>
<b><font color="#207BC3">Debug</font></b> &quot;InitFerrari()&quot;
<b><font color="#207BC3">EndIf</font></b>
<b><font color="#207BC3">EndProcedure</font></b>
<b><font color="#207BC3">Procedure</font></b> <font color="#207BC3">CreateFerrari</font>()
<font color="#207BC3"> Init</font>()
<b><font color="#207BC3">Debug</font></b> &quot;CreateFerrari()&quot;
<b><font color="#207BC3">EndProcedure</font></b>
<b><font color="#207BC3">EndModule</font></b>
<b><font color="#207BC3">Procedure</font></b> <font color="#207BC3">Init</font>() <font color="#207BC3">; Main init procedure, doesn't conflict with the Ferrari Init() procedure</font>
<b><font color="#207BC3">Debug</font></b> &quot;Main init()&quot;
<b><font color="#207BC3">EndProcedure</font></b>
<font color="#207BC3"> Init</font>()
Ferrari::<font color="#207BC3">CreateFerrari</font>()
<b><font color="#207BC3">Debug</font></b> Ferrari::<font color="#924B72">#FerrariName$</font>
<b><font color="#207BC3">Debug</font></b> &quot;------------------------------&quot;
<b><font color="#207BC3">UseModule</font></b> Ferrari <font color="#207BC3">; Now import all public item directly in the main program scope</font>
<font color="#207BC3"> CreateFerrari</font>()
<b><font color="#207BC3">Debug</font></b> <font color="#924B72">#FerrariName$</font>
</font></pre>
</blockquote><p><b>Example:</b> With a common module</p><blockquote>
<pre><font face="Courier New, Courier, mono"size="2">
<font color="#207BC3">; The common module, which will be used by others to share data</font>
<font color="#207BC3">;</font>
<b><font color="#207BC3">DeclareModule</font></b> Cars
<b><font color="#207BC3">Global</font></b> NbCars = 0
<b><font color="#207BC3">EndDeclareModule</font></b>
<b><font color="#207BC3">Module</font></b> Cars
<b><font color="#207BC3">EndModule</font></b>
<font color="#207BC3">; First car module</font>
<font color="#207BC3">;</font>
<b><font color="#207BC3">DeclareModule</font></b> Ferrari
<b><font color="#207BC3">EndDeclareModule</font></b>
<b><font color="#207BC3">Module</font></b> Ferrari
<b><font color="#207BC3">UseModule</font></b> Cars
NbCars+1
<b><font color="#207BC3">EndModule</font></b>
<font color="#207BC3">; Second car module</font>
<font color="#207BC3">;</font>
<b><font color="#207BC3">DeclareModule</font></b> Porche
<b><font color="#207BC3">EndDeclareModule</font></b>
<b><font color="#207BC3">Module</font></b> Porche
<b><font color="#207BC3">UseModule</font></b> Cars
NbCars+1
<b><font color="#207BC3">EndModule</font></b>
<b><font color="#207BC3">Debug</font></b> Cars::NbCars
</font></pre>
</body></html>
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
HTML
1
https://gitee.com/PureBasic/SpiderBasicPreference.git
git@gitee.com:PureBasic/SpiderBasicPreference.git
PureBasic
SpiderBasicPreference
SpiderBasicPreference
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /