Skip to content

Commit d511bbf

Browse files
committed
Change loops help page to control flow
1 parent 9567b68 commit d511bbf

File tree

11 files changed

+22
-19
lines changed

11 files changed

+22
-19
lines changed

Help/commands.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,4 @@ The default starting value for `seed` is zero, so `seed 0` will cause the `rnd`
109109
The `debug` and `print` commands can be used to understand what's happening in your script and help diagnose problems. These are documented in the [debugging](debugging.md) section.
110110

111111
---
112-
[Index](index.md) | Next: [Loops](loops.md)
112+
[Index](index.md) | Next: [Control Flow](control-flow.md)

Help/loops.md renamed to Help/control-flow.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
Loops
1+
Control Flow
22
---
33

4+
## Loops
5+
46
To repeat an instruction (or sequence of instructions) you can use a `for` loop. The simplest form of the for loop takes a [numeric range](expressions.md#ranges), and a block of instructions inside braces. The following loop creates a circle of 5 points (you might use this inside a `path`):
57

68
```swift

Help/examples.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ ShapeScript includes a number of example files that demonstrate various features
55

66
## Ball
77

8-
The Ball example demonstrates how to use the [stencil](csg.md#stencil) command to "paint" patterns on a sphere, as well as a [for loop](loops.md) to generate a star shape that is then [extruded](builders.md#extrude).
8+
The Ball example demonstrates how to use the [stencil](csg.md#stencil) command to "paint" patterns on a sphere, as well as a [for loop](control-flow.md#loops) to generate a star shape that is then [extruded](builders.md#extrude).
99

1010
![Ball](images/ball.png)
1111

1212
## Chessboard
1313

14-
The Chessboard example demonstrates the use of [for loops](loops.md) to duplicate shapes, along with [paths](paths.md), [lathe builders](builders.md#lathe) and [CSG](csg.md) operations.
14+
The Chessboard example demonstrates the use of [for loops](control-flow.md#loops) to duplicate shapes, along with [paths](paths.md), [lathe builders](builders.md#lathe) and [CSG](csg.md) operations.
1515

1616
![Chessboard](images/chessboard.png)
1717

1818
## Cog
1919

20-
The Cog example demonstrates procedural generation of a complex [path](paths.md) using a [for loop](loops.md), as well as the creation of a custom [block](blocks.md) and the use of the [option](blocks.md#options) command to pass parameters.
20+
The Cog example demonstrates procedural generation of a complex [path](paths.md) using a [for loop](control-flow.md#loops), as well as the creation of a custom [block](blocks.md) and the use of the [option](blocks.md#options) command to pass parameters.
2121

2222
![Cog](images/cog.png)
2323

@@ -29,7 +29,7 @@ The Earth example demonstrates use of the [texture](materials.md#texture) comman
2929

3030
## Spring
3131

32-
The Spring example demonstrates advanced use of the [loft](builders.md#loft) command to create a coiled spring shape. This example also demonstrates the use of [for loops](loops.md) and user-defined [options](blocks.md#options).
32+
The Spring example demonstrates advanced use of the [loft](builders.md#loft) command to create a coiled spring shape. This example also demonstrates the use of [for loops](control-flow.md#loops) and user-defined [options](blocks.md#options).
3333

3434
![Spring](images/spring.png)
3535

Help/expressions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Another type of expression you can create is a *range* expression. This consists
7373
1 to 5
7474
```
7575

76-
Ranges are mostly used in [for loops](loops.md):
76+
Ranges are mostly used in [for loops](control-flow.md#loops):
7777

7878
```swift
7979
for i in 1 to 5 {
@@ -117,7 +117,7 @@ for i in 0 to 1 step 0.2 {
117117
}
118118
```
119119

120-
A negative `step` can be used to create a [backwards loop](loops.md#looping-backwards):
120+
A negative `step` can be used to create a [backwards loop](control-flow.md#looping-backwards):
121121

122122
```swift
123123
for i in 5 to 1 step -1 {

Help/import.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import "MyShape.shape"
99

1010
The `import` command loads an external ShapeScript file and evaluates it inside the calling script. Any symbols that are defined in the imported file will become available inside the [scope](scope.md) in which it is loaded, and any geometry created by the imported file will be displayed.
1111

12-
You can import the same file several times in the same script, and import statements can appear inside [loops](loops.md) or [blocks](blocks.md). If you don't want the geometry inside an imported file to be displayed immediately, you can place the import inside a [define](symbols.md) statement:
12+
You can import the same file several times in the same script, and import statements can appear inside [loops](control-flow.md#loops) or [blocks](blocks.md). If you don't want the geometry inside an imported file to be displayed immediately, you can place the import inside a [define](symbols.md) statement:
1313

1414
```swift
1515
define ball {

Help/index.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,11 @@ ShapeScript Help
8383
- [Constructive Solid Geometry](commands.md#constructive-solid-geometry)
8484
- [Random Numbers](commands.md#random-numbers)
8585
- [Debugging](commands.md#debugging)
86-
- [Loops](loops.md)
87-
- [Loop Index](loops.md#loop-index)
88-
- [Looping Backwards](loops.md#looping-backwards)
89-
- [Looping Over Values](loops.md#looping-over-values)
86+
- [Control Flow](control-flow.md)
87+
- [Loops](control-flow.md#loops)
88+
- [Loop Index](control-flow.md#loop-index)
89+
- [Looping Backwards](control-flow.md#looping-backwards)
90+
- [Looping Over Values](control-flow.md#looping-over-values)
9091
- [Blocks](blocks.md)
9192
- [Options](blocks.md#options)
9293
- [Scope](scope.md)

Help/literals.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ Member expressions can be chained, so something like this will also work:
135135
print data.second.x // x component of the position
136136
```
137137

138-
For list-like data, you can use a [for loop](loops.md#looping-over-values) to loop over the top-level values:
138+
For list-like data, you can use a [for loop](control-flow.md#looping-over-values) to loop over the top-level values:
139139

140140
```swift
141141
define positions (

Help/paths.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ roundrect {
148148

149149
The `circle` command is fine for creating complete circles, but what if you want a circular arc or semicircle? Calculating the Bézier control points for that manually would be tedious, so this is where the power of ShapeScript's procedural logic comes in handy.
150150

151-
To create a path procedurally, you can use a [for loop](loops.md) along with [relative transform commands](transforms.md#relative-transforms) such as `rotate`. For example, the following code generates a pentagon:
151+
To create a path procedurally, you can use a [for loop](control-flow.md#loops) along with [relative transform commands](transforms.md#relative-transforms) such as `rotate`. For example, the following code generates a pentagon:
152152

153153
```swift
154154
path {

Help/scope.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This is convenient, because it means that code that defines sub-objects in your
1313

1414
## Loop Scope
1515

16-
The [for loop](loops.md) also creates a local scope around its body. Unlike block scope, loop scope does not apply to transforms or materials, but only to symbols created using the `define` command.
16+
The [for loop](control-flow.md#loops) also creates a local scope around its body. Unlike block scope, loop scope does not apply to transforms or materials, but only to symbols created using the `define` command.
1717

1818
Any symbols defined inside a `for` loop will be restricted to the inside of the loop body. This also applies to the optional loop index variable.
1919

Help/transforms.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ It it possible to apply a negative scale factor, which has the effect of flippin
4545

4646
## Relative Transforms
4747

48-
When defining paths or shapes procedurally using [loops](loops.md) or other logic, you will often wish to position shapes or points using *relative* coordinates, rather than absolutely. You can do this using the `translate`, `rotate` and `scale` commands, which are counterparts to the `position`, `orientation` and `size` options.
48+
When defining paths or shapes procedurally using [loops](control-flow.md#loops) or other logic, you will often wish to position shapes or points using *relative* coordinates, rather than absolutely. You can do this using the `translate`, `rotate` and `scale` commands, which are counterparts to the `position`, `orientation` and `size` options.
4949

5050
Translation is the mathematical term for directional movement. Like `position`, `translate` takes up to 3 values representing offsets along the X Y and Z axes. Unlike `position`, the values do not specify the position of the containing shape, but rather they move the *origin* of the current [scope](scope.md), affecting all subsequently defined shapes.
5151

ShapeScriptTests/MetadataTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class MetadataTests: XCTestCase {
100100
("Expressions", "expressions.md"),
101101
("Functions", "functions.md"),
102102
("Commands", "commands.md"),
103-
("Loops", "loops.md"),
103+
("Control Flow", "control-flow.md"),
104104
("Blocks", "blocks.md"),
105105
("Scope", "scope.md"),
106106
("Debugging", "debugging.md"),
@@ -193,7 +193,7 @@ class MetadataTests: XCTestCase {
193193
continue
194194
}
195195
let text = try XCTUnwrap(String(contentsOf: absoluteURL))
196-
let title = "## \(fragment.replacingOccurrences(of: "-", with: " "))"
196+
let title = "## \(fragment.replacingOccurrences(of: "-", with: "[ -]"))"
197197
if text.range(of: title, options: [.regularExpression, .caseInsensitive]) == nil {
198198
if !url.hasSuffix(file) {
199199
XCTFail("anchor \(url)#\(fragment) referenced in \(file) does not exist")

0 commit comments

Comments
 (0)