# runScript doesn't work to set cursor

**URL:** <https://forum.inductiveautomation.com/t/runscript-doesnt-work-to-set-cursor/6560>\
**Category:** Ignition\
**Created:** [May 22, 2013, 5:57pm UTC](https://forum.inductiveautomation.com/t/runscript-doesnt-work-to-set-cursor/6560 "2013-05-22T17:57:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://forum.inductiveautomation.com/u/Robert)\
**Post date:** [May 22, 2013, 5:57pm UTC](https://forum.inductiveautomation.com/t/runscript-doesnt-work-to-set-cursor/6560/1 "2013-05-22T17:57:05Z")

</div>

I’m trying to change the cursor based on the user roles. ie: if they can poke it, show a hand.

For the cursor property, I have:

```auto
runScript('app.util.showHand')
```

[code]def showHand(default=0):  
import app

```
if app.globals.ok_to_operate():
    return int(12) # cursor code for hand
return int(default)

```

[/code]

Instead of setting the cursor I get:

`ClassCastException: Cannot coerce value '<function showHand at 0x8>' into type: int
`

Edit: ver 7.5.6  
Edit 2: just created a int property and tried to bind the above to that and got the same result. So it’s not the cursor property that’s the problem.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [May 23, 2013, 2:48am UTC](https://forum.inductiveautomation.com/t/runscript-doesnt-work-to-set-cursor/6560/2 "2013-05-23T02:48:28Z")

</div>

Try:

```auto
runScript('app.util.showHand()')
```

---

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://forum.inductiveautomation.com/u/Robert)\
**Post date:** [May 23, 2013, 4:27pm UTC](https://forum.inductiveautomation.com/t/runscript-doesnt-work-to-set-cursor/6560/3 "2013-05-23T16:27:27Z")

</div>

That won’t do what I want.

Unless I bind it to mouse enter and mouse leave events which I guess I can do as a work around.

Why can’t I just return the cursor code as a number as per the example in the docs:

[code]def getTempAt(zipCode):  
import system  
import re #Regular Expression library

response = system.net.httpGet(“[http://xml.weather.yahoo.com/forecastrss?p=](http://xml.weather.yahoo.com/forecastrss?p=)” + str(zipCode))

# NOTE - if you’ve never seen regular expressions before, don’t worry, they look

# confusing even to people who use them frequently.

pattern = re.compile(’._?\<yweather:condition (._?)/\>’, re.DOTALL)  
match = pattern.match(response)  
if match:  
subText = match.group(1)  
temp = re.compile(’._?temp="(._?)"’).match(subText).group(1)  
return int(temp)  
else:  
system.gui.errorBox(“Yahoo weather service changed”)  
return -1

[/code]

[code]And then you could use this expression to bind a property value to the weather:

runScript(“app.weather.getTempAt(‘95818’)”, 15000)

… This would bind a property to the temperature in sunny Sacramento, CA, and would refresh itself every 15 seconds.

[/code]

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [May 23, 2013, 4:32pm UTC](https://forum.inductiveautomation.com/t/runscript-doesnt-work-to-set-cursor/6560/4 "2013-05-23T16:32:25Z")

</div>

You can return the cursor code as a number if you add the parenthesis so that you’re actually calling the function instead of referring to the function object itself…

---

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://forum.inductiveautomation.com/u/Robert)\
**Post date:** [May 23, 2013, 4:45pm UTC](https://forum.inductiveautomation.com/t/runscript-doesnt-work-to-set-cursor/6560/5 "2013-05-23T16:45:02Z")

</div>

Doh! 😊
