Difference between revisions of "MC-Basic:LEFT$"

From SoftMC-Wiki
Jump to: navigation, search
(fixed typo)
Line 1: Line 1:
{{MC-Basic
 
|SHORT FORM=
 
  
 +
LEFT$ 从字符串的左侧返回指定数量的字符。
  
|SYNTAX=
+
在支持 UTF-8 的 4.5.1 及更高版本中,NULL 字符不再会从字符串中被截断,因此行为有所不同:
LEFT$(''<string>, <expression>'')
 
  
|AVAILABILITY=
+
例如,Chr$(0) 的长度(Len)为 1。
All versions
 
  
|DESCRIPTION=
+
在旧版本中,NULL 字符不能出现在字符串的中间,因为在字符串连接(concatenation)过程中,这些字符会被从结果字符串中裁剪掉。
The LEFT$ returns the specified number of characters from the left-hand side of the string.
 
  
In UTF-8 supporting versions 4.5.1 and higher NULL characters are no longer cut
+
== 格式 ==
  
out from strings, resulting in a different behavior:
+
LEFT$(''<string>, <expression>'')
  
Len of Chr$(0) is 1:
+
== 可用版本 ==
  
In former versions NULL characters could not appear in the middle of strings,
+
所有版本
  
since theconcationation process cut these characters from the resulting string.
+
== 类型 ==
  
|TYPE=
+
<''return value''>: String<br/> ''<string>'': String<br/> <''expression''>: Long
<''return value''>: String<br>
 
''<string>'': String<br>
 
<''expression''>: Long
 
  
|RANGE=
+
== 范围 ==
<''return value''>: String<br>
 
''<string>'': String<br>
 
<''expression''>: 0 to MaxLong
 
  
|UNITS=
+
<''return value''>: String<br/> ''<string>'': String<br/> <''expression''>: 0 to MaxLong
  
 +
== 作用域 ==
  
|DEFAULT=
+
Configuration, Task or Terminal
  
 +
== 使用限制 ==
  
|SCOPE=
+
只读
Configuration, Task or Terminal
+
 
 +
== 用例 ==
  
|LIMITATIONS=
+
-->Test=”This string is too long”
Read only
 
  
|EXAMPLE=
+
-->PRINT LEFT$(Test,4)<br/> -->This
-->Test=”This string is too long”<br>
 
  
-->PRINT LEFT$(Test,4)<br>
+
== 参见 ==
                   This
 
  
|SEE ALSO=
+
[[MC-Basic:MID$|MC-Basic:MID$]]
* [[MC-Basic:MID$|MID$]]
 
* [[MC-Basic:RIGHT$|RIGHT$]]
 
  
[[Category:MC-Basic:String Manipulation|LEFT$]]
+
[[MC-Basic:RIGHT$/zh-hans|MC-Basic:RIGHT$/zh-hans]]
}}
 

Revision as of 02:53, 23 January 2026

LEFT$ 从字符串的左侧返回指定数量的字符。

在支持 UTF-8 的 4.5.1 及更高版本中,NULL 字符不再会从字符串中被截断,因此行为有所不同:

例如,Chr$(0) 的长度(Len)为 1。

在旧版本中,NULL 字符不能出现在字符串的中间,因为在字符串连接(concatenation)过程中,这些字符会被从结果字符串中裁剪掉。

格式

LEFT$(<string>, <expression>)

可用版本

所有版本

类型

<return value>: String
<string>: String
<expression>: Long

范围

<return value>: String
<string>: String
<expression>: 0 to MaxLong

作用域

Configuration, Task or Terminal

使用限制

只读

用例

-->Test=”This string is too long”

-->PRINT LEFT$(Test,4)
-->This

参见

MC-Basic:MID$

MC-Basic:RIGHT$/zh-hans