|
1 | 1 | <?xml version="1.0" encoding="UTF-8"?>
|
2 | 2 | <?xml-stylesheet type="text/xsl" href="../helpproject.xsl" ?>
|
3 |
| -<topic template="Default" lasteditedby="robert" version="2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../helpproject.xsd"> |
| 3 | +<topic template="Default" modified="2024-06-10T20:35:42.672+08:00" lasteditedby="Design" version="2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../helpproject.xsd"> |
4 | 4 | <title>ARRAY (FoxPro)</title>
|
5 | 5 | <body>
|
6 | 6 | <header>
|
7 | 7 | <para styleclass="Heading1">ARRAY (FoxPro)</para>
|
8 | 8 | </header>
|
9 |
| - <para styleclass="Normal">The FoxPro dialect in X# has its own Array type. This type is not declared with an AS keyword, but the array type is derived from the context.<br/>The following lines of code all generate a FoxPro compatible array:</para> |
10 | 9 | <para styleclass="Normal"></para>
|
11 |
| - <para styleclass="Code Example"><text style="font-weight:bold; font-style:normal; color:#ff0000;">LOCAL</text><text style="font-weight:normal; font-style:normal; color:#000000;"> </text><text style="font-weight:bold; font-style:normal; color:#ff0000;">ARRAY</text><text style="font-weight:normal; font-style:normal; color:#000000;"> aTest(1,2)      </text><text style="font-weight:bold; font-style:italic; color:#339966;">// LOCAL ARRAY</text><br/><text style="font-weight:bold; font-style:normal; color:#ff0000;">PUBLIC</text><text style="font-weight:normal; font-style:normal; color:#000000;"> </text><text style="font-weight:bold; font-style:normal; color:#ff0000;">ARRAY</text><text style="font-weight:normal; font-style:normal; color:#000000;"> aPublicArray[10]   </text><text style="font-weight:bold; font-style:italic; color:#339966;">// PUBLIC ARRAY</text><br/><text style="font-weight:bold; font-style:normal; color:#ff0000;">DIMENSION</text><text style="font-weight:normal; font-style:normal; color:#000000;"> AnotherArray(3,4)   </text><text style="font-weight:bold; font-style:italic; color:#339966;">// DIMENSION with parentheses , but angled brackets are supported too</text><br/><text style="font-weight:bold; font-style:normal; color:#ff0000;">DECLARE</text><text style="font-weight:normal; font-style:normal; color:#000000;"> ThirdArray[10]      </text><text style="font-weight:bold; font-style:italic; color:#339966;">// DIMENSION with angled brackets, but parentheses are supported too</text></para> |
12 |
| - <para styleclass="Normal">The elements of a Foxpro compatible array are all USUAL.<br/>FoxPro arrays cannot be dynamically sized with AAdd(). To resize them you need to add a DIMENSION statement with new dimensions.</para> |
13 |
| - <para styleclass="Normal">Internally FoxPro arrays are single dimensional arrays. But you can also (re)dimension them as two dimensional. <br/>So the 3rd array in this example can also be treated as a single dimensional array of 12 elements.</para> |
| 10 | + <para styleclass="Normal">X# 中的 FoxPro 方言有自己的 Array 类型。这种类型不是用 AS 关键字声明的,而是根据上下文推导出数组类型。</para> |
14 | 11 | <para styleclass="Normal"></para>
|
15 |
| - <para styleclass="Normal">We advise to use angled brackets to access elements of a FoxPro array. This is not ambiguous and the compiler can resolve that at compile time.</para> |
16 |
| - <para styleclass="Normal">If you want to use parentheses to access FoxPro array elements you need to enable the <link displaytype="text" defaultstyle="true" type="topiclink" href="opt-fox2">/fox </link>compiler option. This compiler option also enables the behavior that assigning a single value to a FoxPro array will result in assigning that value to all elements in the array.</para> |
| 12 | + <para styleclass="Normal">以下代码行都生成兼容 FoxPro 的数组:</para> |
| 13 | + <para styleclass="Code Example"><text style="font-weight:bold; font-style:normal; color:#ff0000;">LOCAL</text><text style="font-weight:normal; font-style:normal; color:#000000;"> </text><text style="font-weight:bold; font-style:normal; color:#ff0000;">ARRAY</text><text style="font-weight:normal; font-style:normal; color:#000000;"> aTest(1,2)      </text><text style="font-weight:bold; font-style:italic; color:#339966;">// LOCAL ARRAY</text><br/><text style="font-weight:bold; font-style:normal; color:#ff0000;">PUBLIC</text><text style="font-weight:normal; font-style:normal; color:#000000;"> </text><text style="font-weight:bold; font-style:normal; color:#ff0000;">ARRAY</text><text style="font-weight:normal; font-style:normal; color:#000000;"> aPublicArray[10]   </text><text style="font-weight:bold; font-style:italic; color:#339966;">// PUBLIC ARRAY</text><br/><text style="font-weight:bold; font-style:normal; color:#ff0000;">DIMENSION</text><text style="font-weight:normal; font-style:normal; color:#000000;"> AnotherArray(3,4)   </text><text style="font-weight:bold; font-style:italic; color:#339966;">// DIMENSION 也支持方括号</text><br/><text style="font-weight:bold; font-style:normal; color:#ff0000;">DECLARE</text><text style="font-weight:normal; font-style:normal; color:#000000;"> ThirdArray[10]      </text><text style="font-weight:bold; font-style:italic; color:#339966;">// DECLARE 使用方括号,但也支持使用括号</text></para> |
| 14 | + <para styleclass="Normal">FoxPro 兼容数组的元素都是 USUAL 类型的。<br/>FoxPro 数组不能使用 AAdd() 动态调整大小。要调整它们的大小,需要使用 DIMENSION 语句和新的维度。</para> |
| 15 | + <para styleclass="Normal">在内部,FoxPro 数组是单维数组。但也可以将它们重新定义为二维数组。<br/>因此,这个示例中的第三个数组也可以被视为包含 12 个元素的单维数组。</para> |
17 | 16 | <para styleclass="Normal"></para>
|
18 |
| - <para styleclass="Normal">Internally FoxPro arrays are implemented as a class that derives from the generic XBase array type.</para> |
19 |
| - <para styleclass="Normal">So all functions in the X# runtime that take an array as parameter will also accept a FoxPro array.<br/>When there is different behavior between the FoxPro implementation of a function or the Xbase implementation then this will be handled at runtime.</para> |
20 |
| - <para styleclass="Heading3">Implementation</para> |
21 |
| - <para styleclass="Normal">The ARRAY type is implemented in the class XSharp.__FoxArray. </para> |
22 |
| - <para styleclass="Normal">The Usualtype of ARRAY has the value 5</para> |
| 17 | + <para styleclass="Normal">建议使用尖括号来访问 FoxPro 数组的元素。这样不会产生歧义,编译器可以在编译时解析。</para> |
| 18 | + <para styleclass="Normal">如果想要使用括号来访问 FoxPro 数组元素,需要启用 <link displaytype="text" defaultstyle="true" type="topiclink" href="opt-fox2">/fox</link>  编译选项。此编译选项还会启用将单个值分配给 FoxPro 数组的所有元素的行为。</para> |
| 19 | + <para styleclass="Normal"></para> |
| 20 | + <para styleclass="Normal">在内部,FoxPro 数组是作为从通用 XBase 数组类型派生的类实现的。</para> |
| 21 | + <para styleclass="Normal">因此,X# 运行时中接受数组作为参数的所有函数也将接受 FoxPro 数组。<br/>当函数的 FoxPro 实现与 Xbase 实现之间存在不同行为时,这将在运行时处理。</para> |
| 22 | + <para styleclass="Normal"></para> |
| 23 | + <para styleclass="Heading3">实现</para> |
| 24 | + <para styleclass="Normal">ARRAY 类型在类 XSharp.__FoxArray 中实现。</para> |
| 25 | + <para styleclass="Normal"></para> |
| 26 | + <para styleclass="Normal">ARRAY 的 Usualtype 值为 5</para> |
23 | 27 | </body>
|
24 | 28 | </topic>
|
0 commit comments