Adjust /while to fit new optional args

8ae7c2330a18952be82fac7c3bf26f803ae67754

Wolfsblvt <wolfsblvt@gmail.com>

1 files changed, +19 -9Showing whitespace changes
public/scripts/variables.js+19 -9
@@ -1342,18 +1342,19 @@ export function registerVariableCommands() {
13421342 typeList: [ARGUMENT_TYPE.VARIABLE_NAME, ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.NUMBER],
13431343 isRequired: true,
13441344 enumProvider: commonEnumProviders.variables('all'),
1345- forceEnum: false,
13461345 }),
13471346 SlashCommandNamedArgument.fromProps({
13481347 name: 'right',
13491348 description: 'right operand',
13501349 typeList: [ARGUMENT_TYPE.VARIABLE_NAME, ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.NUMBER],
1351- isRequired: true,
13521350 enumProvider: commonEnumProviders.variables('all'),
1353- forceEnum: false,
13541351 }),
13551352 new SlashCommandNamedArgument.fromProps({
1356- 'rule', 'comparison rule', [ARGUMENT_TYPE.STRING], true, false, null, [
1353+ name: 'rule',
1354+ description: 'comparison rule',
1355+ typeList: [ARGUMENT_TYPE.STRING],
1356+ defaultValue: 'eq',
1357+ enumList: [
13571358 new SlashCommandEnumValue('gt', 'a > b'),
13581359 new SlashCommandEnumValue('gte', 'a >= b'),
13591360 new SlashCommandEnumValue('lt', 'a < b'),
@@ -1364,10 +1365,15 @@ export function registerVariableCommands() {
13641365 new SlashCommandEnumValue('in', 'a includes b'),
13651366 new SlashCommandEnumValue('nin', 'a not includes b'),
13661367 ],
1367- ),
1368+ forceEnum: true,
1368- new SlashCommandNamedArgument(
1369+ }),
1369- 'guard', 'disable loop iteration limit', [ARGUMENT_TYPE.STRING], false, false, null, commonEnumProviders.boolean('onOff')(),
1370+ SlashCommandNamedArgument.fromProps({
1370- ),
1371+ name: 'guard',
1372+ description: 'disable loop iteration limit',
1373+ typeList: [ARGUMENT_TYPE.STRING],
1374+ defaultValue: 'off',
1375+ enumList: commonEnumProviders.boolean('onOff')(),
1376+ }),
13711377 ],
13721378 unnamedArgumentList: [
13731379 new SlashCommandArgument(
@@ -1404,6 +1410,10 @@ export function registerVariableCommands() {
14041410 <pre><code class="language-stscript">/setvar key=i 0 | /while left=i right=10 rule=lte "/addvar key=i 1"</code></pre>
14051411 adds 1 to the value of "i" until it reaches 10.
14061412 </li>
1413+ <li>
1414+ <pre><code class="language-stscript">/while left={{getvar::currentword}} {: /setvar key=currentword {: /do-something-and-return :}() | /echo The current work is "{{getvar::currentword}}" :}</code></pre>
1415+ executes the defined subcommand as long as the "currentword" variable is truthy (has any content that is not false/empty)
1416+ </li>
14071417 </ul>
14081418 </div>
14091419 <div>