Skip to content

Commit 07c24d8

Browse files
committed
Add reference docs for logical functions
1 parent fa7173e commit 07c24d8

File tree

6 files changed

+663
-0
lines changed

6 files changed

+663
-0
lines changed
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
---
2+
description: Reference for the 'and' DSC configuration document function
3+
ms.date: 01/19/2025
4+
ms.topic: reference
5+
title: and
6+
---
7+
8+
# and
9+
10+
## Synopsis
11+
12+
Returns true if all arguments are true.
13+
14+
## Syntax
15+
16+
```Syntax
17+
and(<arg1>, <arg2>, ...)
18+
```
19+
20+
## Description
21+
22+
The `and()` function evaluates if all arguments are true. It takes two or more boolean arguments
23+
and returns `true` only if every argument is `true`. If any argument is `false`, the function
24+
returns `false`.
25+
26+
This function uses short-circuit evaluation, meaning it returns `false` as soon as it encounters
27+
the first `false` argument without evaluating the remaining arguments.
28+
29+
## Examples
30+
31+
### Example 1 - Basic and operation
32+
33+
This configuration demonstrates basic usage of the `and()` function.
34+
35+
```yaml
36+
# and.example.1.dsc.config.yaml
37+
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
38+
resources:
39+
- name: Echo and result
40+
type: Microsoft.DSC.Debug/Echo
41+
properties:
42+
output: "[and(true, true)]"
43+
```
44+
45+
```bash
46+
dsc config get --file and.example.1.dsc.config.yaml
47+
```
48+
49+
```yaml
50+
results:
51+
- metadata:
52+
Microsoft.DSC:
53+
duration: PT0.1291763S
54+
name: Echo and result
55+
type: Microsoft.DSC.Debug/Echo
56+
result:
57+
actualState:
58+
output: true
59+
messages: []
60+
hadErrors: false
61+
```
62+
63+
### Example 2 - And operation with false value
64+
65+
This example shows the `and()` function returning false when one argument is false.
66+
67+
```yaml
68+
# and.example.2.dsc.config.yaml
69+
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
70+
resources:
71+
- name: Echo and result with false
72+
type: Microsoft.DSC.Debug/Echo
73+
properties:
74+
output: "[and(true, false, true)]"
75+
```
76+
77+
```bash
78+
dsc config get --file and.example.2.dsc.config.yaml
79+
```
80+
81+
```yaml
82+
results:
83+
- metadata:
84+
Microsoft.DSC:
85+
duration: PT0.0329292S
86+
name: Echo and result with false
87+
type: Microsoft.DSC.Debug/Echo
88+
result:
89+
actualState:
90+
output: false
91+
messages: []
92+
hadErrors: false
93+
```
94+
95+
### Example 3 - And operation with multiple conditions
96+
97+
This configuration uses the `and()` function with multiple boolean expressions.
98+
99+
```yaml
100+
# and.example.3.dsc.config.yaml
101+
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
102+
resources:
103+
- name: Echo complex and operation
104+
type: Microsoft.DSC.Debug/Echo
105+
properties:
106+
output: "[and(equals(5, 5), equals('hello', 'hello'), true)]"
107+
```
108+
109+
```bash
110+
dsc config get --file and.example.3.dsc.config.yaml
111+
```
112+
113+
```yaml
114+
results:
115+
- metadata:
116+
Microsoft.DSC:
117+
duration: PT0.0514415S
118+
name: Echo complex and operation
119+
type: Microsoft.DSC.Debug/Echo
120+
result:
121+
actualState:
122+
output: true
123+
messages: []
124+
hadErrors: false
125+
```
126+
127+
## Parameters
128+
129+
### arguments
130+
131+
The `and()` function requires two or more boolean arguments.
132+
133+
```yaml
134+
Type: boolean
135+
Required: true
136+
MinimumCount: 2
137+
MaximumCount: 18446744073709551615
138+
```
139+
140+
## Output
141+
142+
The `and()` function returns `true` if all arguments are `true`, otherwise it returns `false`.
143+
144+
```yaml
145+
Type: boolean
146+
```
147+
148+
<!-- Link reference definitions -->
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
---
2+
description: Reference for the 'bool' DSC configuration document function
3+
ms.date: 01/19/2025
4+
ms.topic: reference
5+
title: bool
6+
---
7+
8+
# bool
9+
10+
## Synopsis
11+
12+
Converts a string or number to a boolean value.
13+
14+
## Syntax
15+
16+
```Syntax
17+
bool(<value>)
18+
```
19+
20+
## Description
21+
22+
The `bool()` function converts a string or number to a boolean value. For string arguments,
23+
it accepts "true" (case-insensitive) which converts to `true`, and "false" (case-insensitive)
24+
which converts to `false`. For numeric arguments, zero converts to `false` and any non-zero
25+
value converts to `true`.
26+
27+
## Examples
28+
29+
### Example 1 - Convert string to boolean
30+
31+
This configuration demonstrates converting string values to boolean.
32+
33+
```yaml
34+
# bool.example.1.dsc.config.yaml
35+
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
36+
resources:
37+
- name: Echo bool from string
38+
type: Microsoft.DSC.Debug/Echo
39+
properties:
40+
output:
41+
trueValue: "[bool('true')]"
42+
falseValue: "[bool('FALSE')]"
43+
```
44+
45+
```bash
46+
dsc config get --file bool.example.1.dsc.config.yaml
47+
```
48+
49+
```yaml
50+
results:
51+
- metadata:
52+
Microsoft.DSC:
53+
duration: PT0.0334711S
54+
name: Echo bool from string
55+
type: Microsoft.DSC.Debug/Echo
56+
result:
57+
actualState:
58+
output:
59+
trueValue: true
60+
falseValue: false
61+
messages: []
62+
hadErrors: false
63+
```
64+
65+
### Example 2 - Convert number to boolean
66+
67+
This example shows the `bool()` function converting numeric values to boolean.
68+
69+
```yaml
70+
# bool.example.2.dsc.config.yaml
71+
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
72+
resources:
73+
- name: Echo bool from numbers
74+
type: Microsoft.DSC.Debug/Echo
75+
properties:
76+
output:
77+
zeroIsFalse: "[bool(0)]"
78+
oneIsTrue: "[bool(1)]"
79+
negativeIsTrue: "[bool(-5)]"
80+
positiveIsTrue: "[bool(42)]"
81+
```
82+
83+
```bash
84+
dsc config get --file bool.example.2.dsc.config.yaml
85+
```
86+
87+
```yaml
88+
results:
89+
- metadata:
90+
Microsoft.DSC:
91+
duration: PT0.0323199S
92+
name: Echo bool from numbers
93+
type: Microsoft.DSC.Debug/Echo
94+
result:
95+
actualState:
96+
output:
97+
zeroIsFalse: false
98+
oneIsTrue: true
99+
negativeIsTrue: true
100+
positiveIsTrue: true
101+
messages: []
102+
hadErrors: false
103+
```
104+
105+
## Parameters
106+
107+
### value
108+
109+
The `bool()` function requires a single argument that is either a string or number.
110+
111+
For strings, valid values are:
112+
- "true" (case-insensitive) - converts to `true`
113+
- "false" (case-insensitive) - converts to `false`
114+
115+
For numbers:
116+
- 0 - converts to `false`
117+
- Any non-zero value - converts to `true`
118+
119+
```yaml
120+
Type: [string, integer]
121+
Required: true
122+
MinimumCount: 1
123+
MaximumCount: 1
124+
```
125+
126+
## Output
127+
128+
The `bool()` function returns a boolean value based on the input argument.
129+
130+
```yaml
131+
Type: boolean
132+
```
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
description: Reference for the 'false' DSC configuration document function
3+
ms.date: 01/19/2025
4+
ms.topic: reference
5+
title: false
6+
---
7+
8+
# false
9+
10+
## Synopsis
11+
12+
Returns the boolean value false.
13+
14+
## Syntax
15+
16+
```Syntax
17+
false()
18+
```
19+
20+
## Description
21+
22+
The `false()` function returns the boolean value `false`. This function takes no arguments and
23+
always returns `false`. It's useful for providing explicit boolean values in configurations
24+
or for logical operations.
25+
26+
## Examples
27+
28+
### Example 1 - Basic false value
29+
30+
This configuration demonstrates basic usage of the `false()` function.
31+
32+
```yaml
33+
# false.example.1.dsc.config.yaml
34+
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
35+
resources:
36+
- name: Echo false value
37+
type: Microsoft.DSC.Debug/Echo
38+
properties:
39+
output: "[false()]"
40+
```
41+
42+
```bash
43+
dsc config get --file false.example.1.dsc.config.yaml
44+
```
45+
46+
```yaml
47+
results:
48+
- name: Echo false value
49+
type: Microsoft.DSC.Debug/Echo
50+
result:
51+
actualState:
52+
output: false
53+
messages: []
54+
hadErrors: false
55+
```
56+
57+
## Parameters
58+
59+
The `false()` function takes no arguments.
60+
61+
```yaml
62+
Type: none
63+
Required: false
64+
MinimumCount: 0
65+
MaximumCount: 0
66+
```
67+
68+
## Output
69+
70+
The `false()` function always returns the boolean value `false`.
71+
72+
```yaml
73+
Type: boolean
74+
```
75+
76+
<!-- Link reference definitions -->

0 commit comments

Comments
 (0)