<html><head><title>SpiderBasic objects</title></head><body bgcolor="#FFFFFF" link="#207BC3" vlink="#003B83" alink="#003B83"><font face="Arial" size="2"><p align="center"><b><font size="5">SpiderBasic objects</font></b></p><p><b>Introduction</b></p><blockquote>The purpose of this section is to describe the behavior, creation, and handling ofobjects in SpiderBasic. For the demonstration, we will use the <a href="../image/index.html">Image</a> object, but thesame logic applies to all other SpiderBasic objects. When creating an Image object, wecan do it in two ways: indexed and dynamic.</blockquote><p><b>I. Indexed numbering</b></p><blockquote>The static, indexed way, allows you to reference an object by a predefinednumeric value. The first available index number is 0 and subsequent indexesare allocated sequentially. This means that if you use the number 0 and thenthe number 1000, 1001 indexes will be allocated and 999 (from 1 to 999) willbe unused, which is not an efficient way to use indexed objects. If you need amore flexible method, use the dynamic way of allocating objects, as describedin section II. The indexed way offers several advantages:<blockquote><p><b></b></p><blockquote>- Easier handling, since no <a href="variables.html">variables</a> or <a href="dim.html">arrays</a> are required. <br>- 'Group' processing, without the need to use an intermediate array. <br>- Use the object in <a href="procedures.html">procedures</a> without declaring anything in <a href="global.html">global</a> (if using a <a href="general_rules.html">constant</a> or a number). <br>- An object that is associated with an index is automatically freed when reusing that index.</blockquote></blockquote>The maximum index number is limited to an upper bound, depending of the objecttype (usually from 5000 to 60000). <a href="enumerations.html">Enumerations</a> are strongly recommended ifyou plan to use sequential constants to identify your objects (which is alsorecommended).<p><b>Example</b></p><blockquote><pre><font face="Courier New, Courier, mono"size="2"><font color="#207BC3"> CreateImage</font>(0, 640, 480) <font color="#207BC3">; Create an image, the n°0</font><font color="#207BC3"> ResizeImage</font>(0, 320, 240) <font color="#207BC3">; Resize the n°0 image</font></font></pre></blockquote><p><b>Example</b></p><blockquote><pre><font face="Courier New, Courier, mono"size="2"><font color="#207BC3"> CreateImage</font>(2, 640, 480) <font color="#207BC3">; Create an image, the n°2</font><font color="#207BC3"> ResizeImage</font>(2, 320, 240) <font color="#207BC3">; Resize the n°2 image</font><font color="#207BC3"> CreateImage</font>(2, 800, 800) <font color="#207BC3">; Create a new image in the n°2 index, the old one is automatically free'ed</font></font></pre></blockquote><p><b>Example</b></p><blockquote><pre><font face="Courier New, Courier, mono"size="2"> <b><font color="#207BC3">For</font></b> k = 0 <b><font color="#207BC3">To</font></b> 9<font color="#207BC3"> CreateImage</font>(k, 640, 480) <font color="#207BC3">; Create 10 different images, numbered from 0 to 9</font><font color="#207BC3"> ResizeImage</font>(k, 320, 240) <font color="#207BC3">; Create a new image in the n°2 index, the old one is automatically free'ed</font><b><font color="#207BC3">Next</font></b></font></pre></blockquote><p><b>Example</b></p><blockquote><pre><font face="Courier New, Courier, mono"size="2"> <font color="#924B72">#ImageBackground</font> = 0<font color="#924B72">#ImageButton</font> = 1<font color="#207BC3"> CreateImage</font>(<font color="#924B72">#ImageBackground</font>, 640, 480) <font color="#207BC3">; Create an image (n°0)</font><font color="#207BC3"> ResizeImage</font>(<font color="#924B72">#ImageBackground</font>, 320, 240) <font color="#207BC3">; Resize the background image</font><font color="#207BC3"> CreateImage</font>(<font color="#924B72">#ImageButton</font> , 800, 800) <font color="#207BC3">; Create an image (n°1)</font></font></pre></blockquote><p><b>II. Dynamic numbering</b></p><blockquote>Sometimes, indexed numbering isn't very handy to handle dynamic situations where we needto deal with an unknown number of objects. SpiderBasic provides an easy and complementary wayto create objects in a dynamic manner. Both methods (indexed and dynamic) can be used togetherat the same time without any conflict. To create a dynamic object, you just have to specifythe <font color="#924B72">#PB_Any</font> constant instead of the indexed number, and the dynamic number will be returned asresult of the function. Then just use this number with the other object functions in the placewhere you would use an indexed number (except to create a new object). This way of object handling can be very useful when usedin combination with a <a href="../list/index.html">list</a>, which is also a dynamic way of storage.<blockquote></blockquote><p><b>Example</b></p><blockquote><pre><font face="Courier New, Courier, mono"size="2"> DynamicImage1 =<font color="#207BC3"> CreateImage</font>(<font color="#924B72">#PB_Any</font>, 640, 480) <font color="#207BC3">; Create a dynamic image</font><font color="#207BC3"> ResizeImage</font>(DynamicImage1, 320, 240) <font color="#207BC3">; Resize the DynamicImage1</font></font></pre></blockquote></blockquote><p><b>Overview of the different SpiderBasic objects</b></p><blockquote>Different SpiderBasic objects (windows, gadgets, sprites, etc.) can use the same range of object numbersagain. So the following objects can be enumerated each one starting at 0 (or other value) and SpiderBasicdiffers them by their type:<blockquote>- <a href="../font/index.html">Font</a> <br>- <a href="../gadget/index.html">Gadget</a> <br>- <a href="../json/index.html">JSON</a> <br>- <a href="../image/index.html">Image</a> <br>- <a href="../menu/index.html">Menu</a> (not <a href="../menu/menuitem.html">MenuItem()</a>, as this is no object) <br>- <a href="../regularexpression/index.html">RegularExpression</a> <br>- <a href="../sound/index.html">Sound</a> <br>- <a href="../sprite/index.html">Sprite</a> <br>- <a href="../toolbar/index.html">ToolBar</a> <br>- <a href="../window/index.html">Window</a> <br>- <a href="../xml/index.html">XML</a> <br></blockquote></body></html>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。