forked from livecode/livecode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtype-convert.lcb
More file actions
89 lines (63 loc) · 2.74 KB
/
type-convert.lcb
File metadata and controls
89 lines (63 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/* Copyright (C) 2003-2016 LiveCode Ltd.
This file is part of LiveCode.
LiveCode is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License v3 as published by the Free
Software Foundation.
LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
/**
This library consists of the operations for performing complex type conversion in LiveCode Builder.
*/
module com.livecode.typeconvert
public foreign handler MCTypeConvertExecSplitStringByDelimiter(in Target as String, in Delimiter as String) returns List binds to "<builtin>"
public foreign handler MCTypeConvertExecCombineListWithDelimiter(in Target as List, in Delimiter as String) returns String binds to "<builtin>"
--
/**
Summary: Splits the string in <Target> into a list of strings, using <Delimiter>
as the delimiter.
Target: An expression that evaluates to a string container.
Delimiter: An expression that evaluates to a string.
The result: The list of strings.
Example:
variable tVar as String
put "first,second,third,fourth,fifth" into tVar
variable tSplit as List
split tVar by "," into tSplit
put element 1 of tSplit into tFirstElement // tFirstElement contains "first"
Description:
Use the split command to convert a string representation of a list into a genuine (ordered) list.
Tags: Type conversion
*/
syntax StringSplitBy is statement
"split" <Target: Expression> "by" <Delimiter : Expression>
begin
MCTypeConvertExecSplitStringByDelimiter(Target, Delimiter)
end syntax
/**
Summary: Combines the list of strings in <Target>, using <Delimiter>
as the delimiter.
Target: An expression that evaluates to a list container.
Delimiter: An expression that evaluates to a string.
The result: The combined string.
Example:
variable tWords as List
put ["A","List","of","words"] into tWords
variable tString as String
combine tWords with " " into tString
-- tString contains "A List of words"
Description:
Use the combine command to convert a list into a string representation of the list.
>*Note:* The list *must* consist entirely of string elements, otherwise the combine command will throw an error.
Tags: Type conversion
*/
syntax CombineListWith is statement
"combine" <Target: Expression> "with" <Delimiter : Expression>
begin
MCTypeConvertExecCombineListWithDelimiter(Target, Delimiter)
end syntax
--
end module