You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: libscript/src/char.mlc
+30-10Lines changed: 30 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -26,12 +26,25 @@ public foreign handler MCCharRepeatForEachChar(inout Iterator as optional pointe
26
26
Summary: Counts the number of chars in <Target>.
27
27
28
28
Target: An expression which evaluates to a string.
29
+
output: The number of chars in <Target>.
29
30
30
31
Example:
31
32
32
-
repeat with x = 1 to the number of chars in tString
33
-
// do something
33
+
variable tVar as int
34
+
variable tSource as string
35
+
put "hello" into tString
36
+
put the number of chars in tString into tVar
37
+
38
+
variable tString as string
39
+
put the empty string into tString
40
+
repeat tVar times
41
+
put "a" after tString
34
42
end repeat
43
+
44
+
// tString contains "aaaaa"
45
+
46
+
Description:
47
+
>*Note:* The number of chars returns the number of codeunits of the target string. It does not perform any grapheme boundary analysis.
35
48
*/
36
49
37
50
syntax CountCharsOf is prefix operator with precedence 1
@@ -46,13 +59,14 @@ end syntax
46
59
47
60
Summary: Designates the char at index <Index> in <Target>.
48
61
Index: An expression which evaluates to a valid integer index of <Target>.
49
-
Target: An expression which evaluates to a string.
50
-
output: Either locates the char at the given index either for use as the target container of another operation,
51
-
or evaluates the char at the given index as the source of another operation.
62
+
Target: An expression which evaluates to a string.
52
63
53
-
Example: delete char 5 of tString // Locates char 5 and removes it from tString
64
+
Example: put the empty string into char 5 of tString // Locates char 5 and removes it from tString
54
65
Example: get char 5 of tString // Evaluates char 5
55
66
67
+
Description:
68
+
Either locates the char at the given index for use as the target container of another operation, or evaluates the char at the given index as the source of another operation.
69
+
56
70
*/
57
71
58
72
syntax SingletonCharOf is prefix operator with precedence 1
@@ -68,13 +82,14 @@ Summary: Designates the chars between indices <Start> and <Finish> in
68
82
69
83
Start: An expression which evaluates to a valid integer index of <Target>.
70
84
Finish: An expression which evaluates to a valid integer index of <Target>.
71
-
Target: An expression which evaluates to a string.
72
-
output: Either locates the chars between the given indices either for use as the target container of another operation,
73
-
or evaluates the chars at the given indices as the source of another operation.
85
+
Target: An expression which evaluates to a string.
74
86
75
87
Example: put tChars into char 5 to 10 of tString // Locates chars 5 to 10 of tString and replace them with tChars
76
88
Example: get char 5 to 10 of tString // Evaluates chars 5 to 10
77
89
90
+
Description:
91
+
Either locates the chars between the given indices either for use as the target container of another operation, or evaluates the chars at the given indices as the source of another operation.
92
+
78
93
*/
79
94
80
95
syntax RangeCharOf is prefix operator with precedence 1
@@ -91,6 +106,9 @@ Summary: Determines whether <Needle> is in <Source>.
91
106
Needle: An expression which evaluates to a char.
92
107
Target: An expression which evaluates to a string.
93
108
output: True if <Needle> is among the chars of <Target>, and false otherwise.
109
+
110
+
Description:
111
+
>*Note:* It is an error if <Needle> evaluates to a string consisting of more than one char.
94
112
*/
95
113
96
114
syntax CharIsIn is neutral binary operator with precedence 1
@@ -157,7 +175,9 @@ Summary: Finds the first or last occurrence of <Needle> before a spec
157
175
Needle: An expression which evaluates to a string.
158
176
Target: An expression which evaluates to a string.
159
177
After: An expression which evaluates to a valid integer index of Target.
160
-
output: Returns the number of chars between the first char of <Target> and the first or last occurrence of <Needle> before index <Before> in <Target>.
178
+
output:
179
+
180
+
Returns the number of chars between the first char of <Target> and the first or last occurrence of <Needle> before index <Before> in <Target>.
161
181
Returns 0 if <Needle> does not occur before index <Before> in <Target>.
162
182
Searches for last occurrence if neither first nor last is specified.
0 commit comments