Question: As part of the setup procedure I am trying to use a slider to set the density of patches which will be displayed and assigned a random value. The slider on the interface for density ranges 0 to 100 and the random value of the patch is set using an input on the interface. This will normally be set in the region go 4. So, if 50% is set the the procedure will assign 50% of the patches with a random value.

When i do i get the following error: "Expected command" and the variable 'error-count' is highlighted in the code.

```
;; The density of patches to be set with a random value is set using variable init-errors on interface.
;; Every patch uses a task which reports a random value.
;; The random value is set using variable error-count on interface
to setup-random
   ask patches [
     if (random-float 100.0) < init-errors
     [setup task random error-count]
   ]
end

```

Answer: 
You need to change:

```
setup task random error-count

```

to

```
setup task [ random error-count ]

```

Anytime the task body isn't just a single primitive (the "concise task syntax"), it needs to be surrounded by square brackets. The error message you're getting happens because `task random` is valid syntax; NetLogo interprets it as short for `task [ random ? ]`. Then it doesn't know what to do with the following `error-count`, hence the error.
I am not entirely clear on the task syntax you are using (in particular, why `setup` is at the beginning of that line) or why you want to use a task here - but that could be a difference in coding style. But the NetLogo compiler is letting you know that it expected a command after the word random but got a value. Since random does expect a value after, I think it's something to do with the setup and task elements. Here's an alternative way of doing what you want, which might be easier. I have also turned the non-zero error patches green so you can see them. This code assumes you have the two sliders you defined in your problem description.

```
patches-own [errors]

to setup-random
   ask patches [
     if (random-float 100.0) < init-errors
     [ set errors random error-count
       set pcolor green ]
   ]
end 

```