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

From SoftMC-Wiki
Jump to: navigation, search
(Undo revision 134059 by Junxian (talk))
 
Line 1: Line 1:
 +
{{MC-Basic
 +
|SHORT FORM=
  
LEFT$ 从字符串的左侧返回指定数量的字符。
 
  
在支持 UTF-8 的 4.5.1 及更高版本中,NULL 字符不再会从字符串中被截断,因此行为有所不同:
+
|SYNTAX=
 +
LEFT$(''<string>, <expression>'')
  
例如,Chr$(0) 的长度(Len)为 1。
+
|AVAILABILITY=
 +
All versions
  
在旧版本中,NULL 字符不能出现在字符串的中间,因为在字符串连接(concatenation)过程中,这些字符会被从结果字符串中裁剪掉。
+
|DESCRIPTION=
 +
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
  
LEFT$(''<string>, <expression>'')
+
out from strings, resulting in a different behavior:
  
== 可用版本 ==
+
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.
  
<''return value''>: String<br/> ''<string>'': String<br/> <''expression''>: Long
+
|TYPE=
 +
<''return value''>: String<br>
 +
''<string>'': String<br>
 +
<''expression''>: Long
  
== 范围 ==
+
|RANGE=
 +
<''return value''>: String<br>
 +
''<string>'': String<br>
 +
<''expression''>: 0 to MaxLong
  
<''return value''>: String<br/> ''<string>'': String<br/> <''expression''>: 0 to MaxLong
+
|UNITS=
  
== 作用域 ==
 
  
Configuration, Task or Terminal
+
|DEFAULT=
  
== 使用限制 ==
 
  
只读
+
|SCOPE=
 
+
Configuration, Task or Terminal
== 用例 ==
 
  
-->Test=”This string is too long”
+
|LIMITATIONS=
 +
Read only
  
-->PRINT LEFT$(Test,4)<br/> -->This
+
|EXAMPLE=
 +
-->Test=”This string is too long”<br>
  
== 参见 ==
+
-->PRINT LEFT$(Test,4)<br>
 +
                   This
  
[[MC-Basic:MID$|MC-Basic:MID$]]
+
|SEE ALSO=
 +
* [[MC-Basic:MID$|MID$]]
 +
* [[MC-Basic:RIGHT$|RIGHT$]]
  
[[MC-Basic:RIGHT$/zh-hans|MC-Basic:RIGHT$/zh-hans]]
+
[[Category:MC-Basic:String Manipulation|LEFT$]]
 +
}}

Latest revision as of 02:54, 23 January 2026

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:

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.

Syntax

LEFT$(<string>, <expression>)

Availability

All versions

Type

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

Range

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

Scope

Configuration, Task or Terminal

Limitations

Read only

Examples

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

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

See Also