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
Copy file name to clipboardExpand all lines: docs/reference/javascript-procedural-proto.md
+23-7Lines changed: 23 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -70,12 +70,12 @@ Sphere {
70
70
71
71
%end
72
72
73
-
- Although not mandatory, the usage of semi-colons for JavaScript statements is highly encouraged.
73
+
- Although not mandatory, the usage of semicolons for JavaScript statements is highly encouraged.
74
74
Which tokens will be considered depends on whether the comment line `# template language: javascript` is present.
75
-
- The `wbfile`module for file manipulation does not need to, and should not, be imported as it is added automatically to each instance of the engine.
76
-
- Performance degradation has been observed when the number of evaluations requested (i.e expressions of the form `%<= ... >%`) is large, generally in the tens of thousands.
75
+
- The modules `wbfile` for file manipulation and `wbenv` for environment variables do not need to, and should not, be imported as they are added automatically to each instance of the engine.
76
+
- Performance degradation has been observed when the number of evaluations requested (i.e. expressions of the form `%<= ... >%`) is large, generally in the tens of thousands.
77
77
This is typically the case when expressions of this form are used to define the coordinates or indexes of, for instance, a [IndexedFaceSet](indexedfaceset.md).
78
-
To greatly speed-up the generation of this sort of PROTO file, it is highly suggested to use a string buffer to which the coordinates are progressively appended and to only evaluate this buffer once at the end, as shown in the following snippet.
78
+
To greatly speedup the generation of this sort of PROTO file, it is highly suggested to use a string buffer to which the coordinates are progressively appended and to only evaluate this buffer once at the end, as shown in the following snippet.
79
79
80
80
%tab-component "generic"
81
81
@@ -183,12 +183,14 @@ The available modules are the following:
183
183
184
184
-`wbutility`: provides commonly needed functions.
185
185
186
-
Additionally, the following module is automatically loaded to the engine and therefore does not need to be imported:
186
+
Additionally, the following modules are automatically loaded to the engine and therefore do not need to be imported:
187
187
188
188
-`wbfile`: provides functions for the reading and writing of files.
189
189
190
-
> **Note:**: contrary to the other JavaScript modules, `wbfile` is a C++ wrapped class and therefore cannot and should not be imported manually, attempting to do so will return an error.
191
-
The functions exported by this module are available globally.
190
+
-`wbenv`: provides functions to get environment variables.
191
+
192
+
> **Note:**: contrary to the other JavaScript modules, `wbfile` and `wbenv` are C++-wrapped classes and therefore cannot and should not be imported manually, attempting to do so will return an error.
193
+
The functions exported by these modules are available globally.
192
194
193
195
The functions exported by each module are:
194
196
@@ -821,6 +823,20 @@ The location of this path can be retrieved from the `context` field object, see
821
823
822
824
%tab-end
823
825
826
+
%tab "wbenv"
827
+
828
+
```javascript
829
+
/**
830
+
* @param{String}variableName;
831
+
* @returns{String}
832
+
*/
833
+
wbenv.getFromEnv(variableName);
834
+
```
835
+
836
+
Returns the value of the environment variable `variableName` or an empty string if it does not exist.
0 commit comments