This repository was archived by the owner on Aug 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 226
Expand file tree
/
Copy pathtry.lcdoc
More file actions
93 lines (70 loc) · 3.38 KB
/
try.lcdoc
File metadata and controls
93 lines (70 loc) · 3.38 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
90
91
92
Name: try
Type: control structure
Syntax:
try
<statementList>
[ catch <errorVariable>
<errorStatementsList> ]
[ finally
<cleanupStatementsList> ]
end try
Summary:
<execute|Executes> a list of <statement|statements>, sending any
<error|errors> to the <try> <control structure|structure> to be handled.
Introduced: 1.0
OS: mac, windows, linux, ios, android
Platforms: desktop, server, mobile
Parameters:
statementList:
The statementList, errorStatementsList, and cleanupStatementsList each
consist of one or more valid LiveCode statements.
errorVariable:
A valid variable name.
errorStatementsList:
cleanupStatementsList:
Description:
Use the <try> <control structure> to execute a series of
<statement|statements> and handle any <error message|error messages> in
the <catch> section, instead of letting LiveCode display the error
window.
**Form:** The <try> <control structure> begins with the word try on a
single line, followed by a list of LiveCode <statement|statements>.
The catch section begins with the <catch> <keyword>, followed by a
<parameter> name. If any <error|errors> occur during <execute|execution>
of the <statementList>, the <error message> is placed in the
<errorVariable> <parameter>, and the <errorStatementsList> is
<execute|executed>. <statement|statements> in the <errorStatementsList>
can refer to the <value> of the errorReport.
The catch section may be followed by an optional <finally> section. The
<cleanupStatementsList> is <execute|executed> normally, even if LiveCode
encountered an <exit> or <pass> statement in the <statementList>.
The <try> <control structure|structure> ends with an <end try>
<statement>.
Each of the statements in the <statementList> is <execute|executed>
normally, just as though the <statementList> were not in a <try>
<control structure|structure>, except that any <error|errors> that would
normally display an error window instead trigger the <catch> section.
This happens even if the <error> is in another <handler> that's
<call|called> from within the <try> <control structure|structure>.
The statements in the catch section are <execute|executed> only if an
<error> occurs. Only <error|errors> that would normally display the
error window are handled by the <catch> section. If the <error> would
not normally display the error window--for example, errors when opening
a <file> with the <open file> <command> --it doesn't <trigger> the
<catch> section.
The statements in the <finally> section are <execute|executed> whether
or not there is an <error>. Since the <finally> section is always
<execute|executed> even if the <statementList> contains an <exit> or
<pass> <statement>, it can be used for final cleanup actions such as
deleting <variable|variables>. The <finally> section is an optional part
of the <try> <control structure|structure>.
>*Note:* The <try> <control structure> is implemented internally as a
> <command> and appears in the <commandNames>.
References: open file (command), pass (control structure),
exit (control structure), try (control structure),
throw (control structure), value (function), commandNames (function),
error message (glossary), variable (glossary), call (glossary),
execute (glossary), command (glossary), control structure (glossary),
error (glossary), trigger (glossary), keyword (glossary),
parameter (glossary), statement (glossary), handler (glossary),
file (keyword), end try (keyword), finally (keyword), catch (keyword)