1 |
schoenebeck |
2581 |
on init |
2 |
|
|
|
3 |
|
|
{ These are preprocessor statements, which are not executed at runtime. |
4 |
|
|
They are instead processed at early parser stage. You can set a |
5 |
|
|
preprocessor condition with: |
6 |
|
|
|
7 |
|
|
SET_CONDITION(<condition-name>) |
8 |
|
|
|
9 |
|
|
Then you can use such preprocessor conditions to conditionally let the |
10 |
|
|
script parser know which code parts shall be used and which code parts |
11 |
|
|
shall be ignored. The ignored code parts will never be executed and thus |
12 |
|
|
will not waste any resources at runtime. |
13 |
|
|
|
14 |
|
|
There are also built-in coditions, already defined by the sampler, which |
15 |
|
|
allows you to execude script parts depending on certain circumstances. |
16 |
|
|
} |
17 |
|
|
|
18 |
|
|
SET_CONDITION(foo) |
19 |
|
|
|
20 |
|
|
{ This will raise a warning, because it has already been set before. } |
21 |
|
|
SET_CONDITION(foo) |
22 |
|
|
|
23 |
|
|
USE_CODE_IF(foo) |
24 |
|
|
message("SET_CONDITION works.") |
25 |
|
|
END_USE_CODE |
26 |
|
|
|
27 |
|
|
USE_CODE_IF_NOT(foo) |
28 |
|
|
message("SET_CONDITION does not work!") |
29 |
|
|
END_USE_CODE |
30 |
|
|
|
31 |
|
|
RESET_CONDITION(foo) |
32 |
|
|
|
33 |
|
|
USE_CODE_IF_NOT(foo) |
34 |
|
|
message("RESET_CONDITION works.") |
35 |
|
|
END_USE_CODE |
36 |
|
|
|
37 |
|
|
USE_CODE_IF(foo) |
38 |
|
|
message("RESET_CONDITION does not work!") |
39 |
|
|
END_USE_CODE |
40 |
|
|
|
41 |
|
|
|
42 |
|
|
SET_CONDITION(bar) |
43 |
|
|
|
44 |
|
|
USE_CODE_IF(bar) |
45 |
|
|
SET_CONDITION(bla) |
46 |
|
|
USE_CODE_IF(bla) |
47 |
|
|
message("Nested conditions work.") |
48 |
|
|
END_USE_CODE |
49 |
|
|
USE_CODE_IF_NOT(bla) |
50 |
|
|
message("Nested conditions do not work!") |
51 |
|
|
END_USE_CODE |
52 |
|
|
END_USE_CODE |
53 |
|
|
|
54 |
|
|
{ If you uncomment the following, it will throw an error. } |
55 |
|
|
{ RESET_CONDITION(somethingthatdoesnotexist) } |
56 |
|
|
|
57 |
|
|
end on |