---
name: "ns_for"
section: "3aolserver"
platform: "linux"
package: "aolserver4-dev"
version: "4.5.1-18.1"
release: "Debian 9 (Stretch)"
platforms: ["linux"]
url: "https://new.carta.tech/ns_for"
---

# ns\_for(3aolserver)

Replacements for standard Tcl loop commands which enable monitoring and control

```

```

## NAME

ns\_for, ns\_foreach, ns\_while, ns\_lctl - Replacements for standard Tcl loop commands which enable monitoring and control

## SYNOPSIS

```
ns_for start test next body
ns_foreach varname list body
ns_foreach varlist1 list1 ?varlist2 list2 ...? body
ns_while test body
ns_lctl cancel id
ns_lctl eval id script
ns_lctl info id
ns_lctl install command
ns_lctl list
ns_lctl pause id
ns_lctl result id
```

```

```

## DESCRIPTION

The **ns\_for**, **ns\_foreach**, and **ns\_while** commands are replacements for cooresponding Tcl commands with the additional capability of monitoring and control through the **ns\_lctl** command.

- **ns\_for** *start test next body*

  See the *[for(n)](/for/n.md)* man page for usage.

- **ns\_foreach** *start test next body*

  See the *[foreach(n)](/foreach/n.md)* man page for usage.

- **ns\_foreach** *varlist1 list1* ?*varlist2 list2 ...*? *body*

  See the *[foreach(n)](/foreach/n.md)* man page for usage.

- **ns\_while** *test body*

  See the *[while(n)](/while/n.md)* man page for usage.

- **ns\_lctl cancel** *id*

  Mark the given loop to cancel at the next iteration, resulting in the loop returning with **TCL\_ERROR**.

- **ns\_lctl eval** *id script*

  - **ns\_lctl info** *id*

  - **ns\_lctl install** *command*

  - **ns\_lctl list**

  - **ns\_lctl pause** *id*

  - **ns\_lctl result** *id*

  ## SEE ALSO

[for(n)](/for/n.md), [foreach(n)](/foreach/n.md), [while(n)](/while/n.md)

## KEYWORDS

threads, iteration, list, looping, cancel
