# toInt Expression Question

**URL:** <https://forum.inductiveautomation.com/t/toint-expression-question/12313>\
**Category:** Ignition\
**Created:** [November 1, 2016, 2:44pm UTC](https://forum.inductiveautomation.com/t/toint-expression-question/12313 "2016-11-01T14:44:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![scicco](https://avatars.discourse-cdn.com/v4/letter/s/e0b2c6/32.png) [@scicco](https://forum.inductiveautomation.com/u/scicco)\
**Post date:** [November 1, 2016, 2:44pm UTC](https://forum.inductiveautomation.com/t/toint-expression-question/12313/1 "2016-11-01T14:44:11Z")

</div>

Hello,

I’m using the toInt expression to see if the last character of a folder name is a number. It appears to interpret “f” and “n” as 0 and “t” and “y” as 1 (upper and lower case). I’m guessing it interprets those as false / no and true / yes and doing what the user manual suggests it’s doing:

The toInt expression says “if value is a string, it is parsed to see if it represents an integer”.

Is there a way around this or maybe another expression I’m missing?

Thanks,  
Steve

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [November 3, 2016, 8:15pm UTC](https://forum.inductiveautomation.com/t/toint-expression-question/12313/2 "2016-11-03T20:15:50Z")

</div>

Hi, Steve!

Luckily, there are only four of them to watch for. The following will give a -1 for anything not ending in 0-9.

`switch(lower(right(folderName,1)),
		't','f','y','n',
		-1,-1,-1,-1,
		toInt(lower(right(folderName,1)),-1)
		)`

---

<div class="post-metadata">

**Author:** ![scicco](https://avatars.discourse-cdn.com/v4/letter/s/e0b2c6/32.png) [@scicco](https://forum.inductiveautomation.com/u/scicco)\
**Post date:** [November 4, 2016, 12:14pm UTC](https://forum.inductiveautomation.com/t/toint-expression-question/12313/3 "2016-11-04T12:14:14Z")

</div>

Hi Jordan,

Thanks for the reply! I haven’t been receiving notifications on topic posts even though I checked “Notify me when a reply is posted” so didn’t see this until now. I came up with the following using a shared Python script yesterday afternoon:

`// toInt expression was returning numbers for "f", "n", "t", "y" so use scripting to check if last character of name is number
if(runScript("shared.Helper.is_number", 0, right("{Machine_ID_Code}", 1)), 
   right("{Machine_ID_Code}", 1),
   ""
   )`

Both solutions seem kind of hacky but at least they work. Thanks again!

Steve
