Explore Enterprise Education Gitee Premium Gitee AI AI teammates
Fetch the repository succeeded.
Donate
Please sign in before you donate.
Scan WeChat QR to Pay
Cancel
Complete
Prompt
Switch to Alipay.
OK
Cancel
1 Star 0 Fork 0

PureBasic/SpiderBasicPreference

Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
Already have an account? Sign in
文件
master
Branches (1)
master
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
The license selected for the repository is subject to the license used by the main branch of the repository.
master
Branches (1)
master
Clone or Download
Clone/Download
Prompt
To download the code, please copy the following command and execute it in the terminal
To ensure that your submitted code identity is correctly recognized by Gitee, please execute the following command.
When using the SSH protocol for the first time to clone or push code, follow the prompts below to complete the SSH configuration.
1 Generate RSA keys.
2 Obtain the content of the RSA public key and configure it in SSH Public Keys
To use SVN on Gitee, please visit the usage guide
When using the HTTPS protocol, the command line will prompt for account and password verification as follows. For security reasons, Gitee recommends configure and use personal access tokens instead of login passwords for cloning, pushing, and other operations.
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # Private Token
master
Branches (1)
master
structures.html 7.04 KB
Copy Edit Raw Blame History
麦壳饼 authored 2016年07月26日 10:47 +08:00 . chuci tijiao
<html><head><title>Structures</title></head>
<body bgcolor="#FFFFFF" link="#207BC3" vlink="#003B83" alink="#003B83">
<font face="Arial" size="2"><p align="center"><b><font size="5">Structures</font></b></p>
<br><b>Syntax</b><blockquote><pre><font face="Courier New, Courier, mono"size="2"><b><font color="#207BC3">Structure</font></b> &lt;name&gt; [<b><font color="#207BC3">Extends</font></b> &lt;name&gt;]
...
<b><font color="#207BC3">EndStructure</font></b>
</font></pre></blockquote>
<b>Description</b><br><blockquote>
<b><font color="#207BC3">Structure</font></b> is useful to define user type, and access some OS memory areas. Structures can be used
to enable faster and easier handling of data files. It is very useful as you can group into the same
object the information which are common. Structures fields are accessed with the <b><font color="#207BC3">\</font></b> option. Structures
can be nested. Statics arrays are supported inside structures. <br>
<br>
Dynamic objects like arrays, lists and maps are supported inside structure and are automatically initialized
when the object using the structure is created. To declare such field, use the following keywords:
<b><font color="#207BC3">Array</font></b>, <b><font color="#207BC3">List</font></b> and <b><font color="#207BC3">Map</font></b>. <br>
<br>
The optional <b><font color="#207BC3">Extends</font></b> parameter allows to extends another structure with new fields. All fields
found in the extended structure will be available in the new structure and will be placed before
the new fields. This is useful to do basic inheritance of structures. <br>
<br>
<a href="compilerfunctions.html">SizeOf</a> can be used with structures to get the size of the structure and <a href="compilerfunctions.html">OffsetOf</a> can be used to retrieve
the index of the specified field. <br>
<br>
Please note, that in structures a static array[] doesn't behave like the normal BASIC array (defined using <a href="dim.html">Dim</a>)
to be conform to the C/C++/JavaScript structure format (to allow direct API structure porting). This means that a[2] will
allocate an array from 0 to 1 where Dim a(2) will allocate an array from 0 to 2.
<br>
<br>
When using <a href="memory.html">pointers</a> in structures, the '*' has to be omitted when using the field, once more to ease API code porting. It can be
seen as an oddity (and to be honest, it is) but it's like that since the very start of SpiderBasic and many, many sources rely
on that so it won't be changed.
<br>
<br>
When using a lot of structure fields you can use the <a href="with_endwith.html">With</a> : <a href="with_endwith.html">EndWith</a>
keywords to reduce the amount of code to type and ease its readability.
<br>
<br>
It's possible to perform a full structure copy by using the equal affectation between two structure element of the same type.
<br>
<br>
<a href="compilerfunctions.html">ClearStructure</a> can be used to clear a structured memory area. It's for advanced use only, when
<a href="memory.html">pointers</a> are involved. <br>
</blockquote><p><b>Example</b></p><blockquote>
<pre><font face="Courier New, Courier, mono"size="2"> <b><font color="#207BC3">Structure</font></b> Person
Name.s
ForName.s
Age.w
<b><font color="#207BC3">EndStructure</font></b>
<b><font color="#207BC3">Dim</font></b> <font color="#207BC3">MyFriends</font>.Person(100)
<font color="#207BC3">; Here the position '0' of the array MyFriend()</font>
<font color="#207BC3">; will contain one person and it's own information</font>
<font color="#207BC3"> MyFriends</font>(0)\Name = &quot;Andersson&quot;
<font color="#207BC3"> MyFriends</font>(0)\Forname = &quot;Richard&quot;
<font color="#207BC3"> MyFriends</font>(0)\Age = 32
</font></pre>
</blockquote><p><b>Example:</b> A more complex structure (Nested and static array)</p><blockquote>
<pre><font face="Courier New, Courier, mono"size="2"> <b><font color="#207BC3">Structure</font></b> Window
*NextWindow.Window <font color="#207BC3">; Points to another window object</font>
x.w
y.w
Name.s[10] <font color="#207BC3">; 10 Names available (from 0 to 9)</font>
<b><font color="#207BC3">EndStructure</font></b>
</font></pre>
</blockquote><p><b>Example:</b> Extended structure</p><blockquote>
<pre><font face="Courier New, Courier, mono"size="2"> <b><font color="#207BC3">Structure</font></b> MyPoint
x.l
y.l
<b><font color="#207BC3">EndStructure</font></b>
<b><font color="#207BC3">Structure</font></b> MyColoredPoint <b><font color="#207BC3">Extends</font></b> MyPoint
color.l
<b><font color="#207BC3">EndStructure</font></b>
ColoredPoint.MyColoredPoint\x = 10
ColoredPoint.MyColoredPoint\y = 20
ColoredPoint.MyColoredPoint\color =<font color="#207BC3"> RGB</font>(255, 0, 0)
</font></pre>
</blockquote><p><b>Example:</b> Structure copy</p><blockquote>
<pre><font face="Courier New, Courier, mono"size="2"> <b><font color="#207BC3">Structure</font></b> MyPoint
x.l
y.l
<b><font color="#207BC3">EndStructure</font></b>
LeftPoint.MyPoint\x = 10
LeftPoint\y = 20
RightPoint.MyPoint = LeftPoint
<b><font color="#207BC3">Debug</font></b> RightPoint\x
<b><font color="#207BC3">Debug</font></b> RightPoint\y
</font></pre>
</blockquote><p><b>Example:</b> Dynamic object</p><blockquote>
<pre><font face="Courier New, Courier, mono"size="2"> <b><font color="#207BC3">Structure</font></b> Person
Name$
Age.l
<b><font color="#207BC3">List</font></b> <font color="#207BC3">Friends$</font>()
<b><font color="#207BC3">EndStructure</font></b>
John.Person
John\Name$ = &quot;John&quot;
John\Age = 23
<font color="#207BC3">; Now, add some friends to John</font>
<font color="#207BC3">;</font>
<font color="#207BC3"> AddElement</font>(John\<font color="#207BC3">Friends$</font>())
John\<font color="#207BC3">Friends$</font>() = &quot;Jim&quot;
<font color="#207BC3"> AddElement</font>(John\<font color="#207BC3">Friends$</font>())
John\<font color="#207BC3">Friends$</font>() = &quot;Monica&quot;
<b><font color="#207BC3">ForEach</font></b> John\<font color="#207BC3">Friends$</font>()
<b><font color="#207BC3">Debug</font></b> John\<font color="#207BC3">Friends$</font>()
<b><font color="#207BC3">Next</font></b>
</font></pre>
</blockquote><p><b>Example:</b> Pointers</p><blockquote>
<pre><font face="Courier New, Courier, mono"size="2"> <b><font color="#207BC3">Structure</font></b> Person
*Next.Person <font color="#207BC3">; Here the '*' is mandatory to declare a pointer</font>
Name$
Age.b
<b><font color="#207BC3">EndStructure</font></b>
Timo.Person\Name$ = &quot;Timo&quot;
Timo\Age = 25
Fred.Person\Name$ = &quot;Fred&quot;
Fred\Age = 25
Timo\Next = @Fred <font color="#207BC3">; When using the pointer, the '*' is omitted</font>
<b><font color="#207BC3">Debug</font></b> Timo\Next\Name$ <font color="#207BC3">; Will print 'Fred'</font>
</font></pre>
</body></html>
Loading...
Report
Report success
We will send you the feedback within 2 working days through the letter!
Please fill in the reason for the report carefully. Provide as detailed a description as possible.
Please select a report type
Cancel
Send
误判申诉

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

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

取消
提交

Releases

No release

Contributors

All

Language(Optional)

Activities

can not load any more
Edit
About
Homepage
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
HTML
1
https://gitee.com/PureBasic/SpiderBasicPreference.git
git@gitee.com:PureBasic/SpiderBasicPreference.git
PureBasic
SpiderBasicPreference
SpiderBasicPreference
master
Going to Help Center

Search

Comment
Repository Report
Back to the top
Login prompt
This operation requires login to the code cloud account. Please log in before operating.
Go to login
No account. Register

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