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
Summary: Executes a list of statements depending on the value of a condition.
17
+
18
+
Parameters:
19
+
IfCondition(bool): An expression which evaluates to a boolean.
20
+
IfStatementList: A set of statements.
21
+
ElseCondition(bool): An expression which evaluates to a boolean.
22
+
ElseIfStatementList: A set of statements.
23
+
ElseStatementList: A set of statements.
24
+
25
+
Description:
26
+
Use the if control structure to execute a statement (or list of statements) only under certain circumstances. If <IfCondition> evaluates to true, the statements in <IfStatementList> are executed. For each condition <ElseCondition> such that none of the previous conditions evaluates to true, the condition is evaluated and the corresponding statements in <ElseIfStatementList> are executed. If none of the conditions evaluate to true, the statements in <ElseStatementList> are executed.
27
+
28
+
Name: RepeatForEach
29
+
30
+
Type: control structure
31
+
32
+
Syntax:
33
+
repeat for each <Iterator> in <Container>
34
+
<StatementList>
35
+
end repeat
36
+
37
+
Summary: Executes a list of statements until the <Iterator> is exhausted.
38
+
39
+
Parameters:
40
+
Iterator: Any iterator expression.
41
+
Container: The container over which to iterate.
42
+
StatementList: A set of statements.
43
+
44
+
Example:
45
+
variable tElement
46
+
variable tNumbers as list
47
+
put the empty list into tNumbers
48
+
49
+
repeat for each element tElement in ["a", 1, 2, 3, "b", "c", 4]
50
+
if tElement is a number then
51
+
push tElement onto tNumbers
52
+
end if
53
+
end repeat
54
+
55
+
// tNumbers contains [1, 2, 3, 4]
56
+
57
+
Description:
58
+
Use the repeat for each control structure to iterate though the chars of a string, bytes of data, elements of a list or array, or keys of an array.
59
+
>*Note:* The variable which contains the iterand must be declared prior to being used in the repeat loop.
Summary: Executes a list of statements continually.
73
+
74
+
Parameters:
75
+
StatementList: A set of statements.
76
+
77
+
Example:
78
+
variable tCount as number
79
+
variable tList as list
80
+
put [ 1, 2, 3, 4, 5, 6, 7, 8, "A", 9, 10 ] into tList
81
+
put 0 into tCount
82
+
repeat forever
83
+
if tList[tCount] is not a number then
84
+
exit repeat
85
+
end if
86
+
add 1 to tCount
87
+
end repeat
88
+
89
+
// tCount is 8
90
+
91
+
Description:
92
+
Use the repeat forever structure to execute a set of statements until either an error is thrown, or exit repeat is executed.
93
+
94
+
Name: RepeatTimes
95
+
96
+
Type: control structure
97
+
98
+
Syntax:
99
+
repeat <Count> times
100
+
<StatementList>
101
+
end repeat
102
+
103
+
Summary: Executes a list of statements a given number of times.
104
+
105
+
Parameters:
106
+
Count(integer): An expression which evaluates to an integer.
107
+
StatementList: A set of statements.
108
+
109
+
Example:
110
+
public handler TwoToThePower(in pOperand as integer) as number
111
+
112
+
if pOperand is 0 then
113
+
return 1
114
+
end if
115
+
116
+
variable tCount as number
117
+
put the abs of pOperand into tCount
118
+
119
+
variable tResult as number
120
+
put 1 into tResult
121
+
repeat tCount times
122
+
multiply tResult by 2
123
+
end repeat
124
+
125
+
if pOperand < 0 then
126
+
return 1 / tResult
127
+
end if
128
+
129
+
return tResult
130
+
end handler
131
+
132
+
Description:
133
+
Use the repeat <Count> times structure to execute a set of statements a given number of times, when the statements executed do not rely on knowing which iteration the repeat loop is on.
134
+
135
+
Name: RepeatWhile
136
+
137
+
Type: control structure
138
+
139
+
Syntax:
140
+
repeat while <Condition>
141
+
<StatementList>
142
+
end repeat
143
+
144
+
Summary: Executes a list of statements while a condition continues to be true.
145
+
146
+
Parameters:
147
+
Condition(bool): An expression which evaluates to a boolean.
148
+
StatementList: A set of statements.
149
+
150
+
Description:
151
+
Use the repeat while <Condition> structure to execute a set of statements repeatedly, while the <Condition> continues to evaluate to true.
152
+
153
+
Name: RepeatUntil
154
+
155
+
Type: control structure
156
+
157
+
Syntax:
158
+
repeat until <Condition>
159
+
<StatementList>
160
+
end repeat
161
+
162
+
Summary: Executes a list of statements until a condition becomes true.
163
+
164
+
Parameters:
165
+
Condition(bool): An expression which evaluates to a boolean.
166
+
StatementList: A set of statements.
167
+
168
+
Description:
169
+
Use the repeat until <Condition> structure to execute a set of statements repeatedly, until the <Condition> evaluates to true.
170
+
171
+
Name: RepeatWith
172
+
173
+
Type: control structure
174
+
175
+
Syntax:
176
+
repeat with <Counter> from <Start> ( up | down ) to <Finish> [ by <Step> ]
177
+
<StatementList>
178
+
end repeat
179
+
180
+
Summary: Executes a list of statements
181
+
182
+
Parameters:
183
+
Counter: A numeric variable.
184
+
Start(number): The initial value of <Counter>
185
+
Finish(number): The boundary value of <Counter>
186
+
Step(number): The value by which to increase or decrease the <Counter>
187
+
StatementList: A set of statements.
188
+
189
+
Example:
190
+
191
+
Description:
192
+
Use the repeat with <Counter> structure to execute a set of statements until the value of <Counter> reaches or crosses (depending on iteration direction) the value of <Finish>. The counter is increased (or decreased) by <Step> on each iteration of the loop.
Copy file name to clipboardExpand all lines: engine/src/widget.mlc
+111-2Lines changed: 111 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,8 @@
17
17
/*
18
18
This library consists of the operations on widgets provided by LiveCode Builder.
19
19
20
+
Tags: Widget
21
+
20
22
Name: OnOpen
21
23
Type: message
22
24
Syntax: OnOpen
@@ -320,30 +322,81 @@ public foreign handler MCWidgetEvalInEditMode(out rInEditMode as bool) as undefi
320
322
public foreign handler MCWidgetExecDispatch(in pIsFunction as bool, in pMessage as string) as any binds to "<builtin>"
321
323
public foreign handler MCWidgetExecDispatchWithArguments(in pIsFunction as bool, in pMessage as string, in pArguments as optional list) as any binds to "<builtin>"
@@ -363,12 +416,34 @@ public foreign handler MCWidgetSetWidth(in pWidth as real) as undefined binds to
363
416
public foreign handler MCWidgetGetHeight(out rHeight as real) as undefined binds to "<builtin>"
364
417
public foreign handler MCWidgetSetHeight(in pHeight as real) as undefined binds to "<builtin>"
365
418
419
+
/*
420
+
Summary: Obtains a reference to the widget script object.
421
+
422
+
Returns: The widget script object.
423
+
424
+
Example:
425
+
426
+
Description:
427
+
428
+
*/
429
+
366
430
syntax MyScriptObject is expression
367
431
"my" "script" "object"
368
432
begin
369
433
MCWidgetGetScriptObject(output)
370
434
end syntax
371
435
436
+
/*
437
+
Summary:
438
+
439
+
Returns: The rectangle of the widget script object.
440
+
441
+
Example:
442
+
443
+
Description:
444
+
445
+
*/
446
+
372
447
syntax MyRectangle is expression
373
448
"my" "rectangle"
374
449
begin
@@ -464,16 +539,50 @@ end syntax
464
539
public foreign handler MCWidgetEvalIsPointWithinRect(in pPoint as Point, in pRect as Rectangle, out rWithin as bool) as undefined binds to "<builtin>"
465
540
public foreign handler MCWidgetEvalIsPointNotWithinRect(in pPoint as Point, in pRect as Rectangle, out rNotWithin as bool) as undefined binds to "<builtin>"
466
541
542
+
/*
543
+
Summary: Determines whether a point is within a rectangle.
544
+
Point: An expression that evaluates to a Point.
545
+
Rect: An expression that evaluates to a Rectangle.
546
+
547
+
Example:
548
+
variable tClick as Point
549
+
put the click position into tClick
550
+
551
+
variable tRect as Rectangle
552
+
put my bounds into tRect
553
+
554
+
if tClick is within tRect then
555
+
// click was within widget bounds
556
+
end if
557
+
*/
558
+
467
559
syntax IsPointWithinRect is neutral binary operator with precedence 5
0 commit comments