Skip to content

Commit aeac805

Browse files
authored
Update 768-string-sinput.markdown
1 parent f2761a3 commit aeac805

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed
Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,32 @@
11
# SINPUT
22

3-
> SINPUT src; var [, delim] [,var [, delim]] ...
3+
> SINPUT src; var1 [, delim1] [,var2 [, delim2]] ... [,varN [, delimN]]
44
5-
Splits the string 'src' into variables which are separated by delimiters.
5+
Splits the string `src` into substrings which are separated by delimiters `delim1` to `delimN` and returns the substrings as `var1` to `varN`. Delimiters can be single characters, numbers or strings.
66

7-
```
8-
src = "if x>1 then y"
9-
SINPUT src; vif, " ", vcond, "then", vdo
10-
print vif, vcond, vdo ' output: if x>1 y
11-
```
7+
### Example 1: Split string with delimiter ","
128

139
```
1410
src = "1456,Peter,8"
11+
1512
SINPUT src; id, ",", name, ",", age
16-
print "ID: " + id
13+
14+
print "ID : " + id
1715
print "Name: " + name
18-
print "Age: " + age
16+
print "Age : " + age
17+
18+
' Output:
19+
' ID : 1456
20+
' Name: Peter
21+
' Age : 8
1922
```
23+
24+
### Example 2: Split string with complex delimiters
25+
26+
```
27+
src = "if x>1 then y"
28+
SINPUT src; vif, " ", vcond, "then", vdo
29+
print vif, vcond, vdo ' Output: if x>1 y
30+
```
31+
32+

0 commit comments

Comments
 (0)