## isnumber Function

Posts: 10
Joined: Wed Sep 17, 2014 8:38 am

Post by WallyD444 » Mon Jul 13, 2015 1:57 pm
Is there a comparable function to isnumber in GAD? I'm trying to base an if statement on whether the variable returned is a number (0-9), I've tried this:

\${decimal(fnameChar)==1 OR decimal(fnameChar)==2 OR decimal(fnameChar)==3 OR decimal(fnameChar)==4 OR decimal(fnameChar)==5 OR decimal(fnameChar)==6 OR decimal(fnameChar)==7 OR decimal(fnameChar)==8 OR decimal(fnameChar)==9}

but it fails with this error: [8099 - print] An unexpected error occurred. Function 'Decimal': Parameter '1' must be a number. Function definition: 'Decimal(number) returns decimal'

I assume it's because the variable fnameChar is a 't'. I was hoping it would say 'well, "t" is not a 1 or 2 or ect. . .' and carry on.

Support Specialist
Posts: 592
Joined: Tue Jul 17, 2012 2:12 pm

Post by Support_Rick » Mon Jul 13, 2015 4:09 pm
WallyD...

There isn't an "IsNumeric" function currently built into GAD. There are 2 options though.

1. Take advantage of an SQL Function like MSSQL IsNumeric() and return the value (condition) you're looking for then continue as needed.

2. Use the Utility below that I created some time ago ... it will help you identify whether or not the value passed into the Utility is Numeric or not.

**NOTE** .. this can be tweaked to include decimals, etc. Currently set for whole numbers only.
Code: Select all
``````<project name="IsNumeric" mainModule="Main" version="2.0" logLevel="silent">

<module name="Main">

<raiseError label="Have MyVal?" version="1.0" executeOnlyIf="\${ IsEmpty( MyVal ) }">
<message>MyVal cannot be blank!  Try again ...</message>
</raiseError>

<setVariable label="Setvar: IsNumeric" name="IsNumeric" value="\${ If( IsEmpty( Replace( MyVal , &apos;[0-9]&apos;, &apos;&apos;)), true, false ) }" version="2.0" />

<print label="Status" version="1.0">
<![CDATA[
====================================
MyVal: \${MyVal} -- is Numeric? \${IsNumeric}
====================================]]>
</print>

</module>

<variable name="MyVal" value="" />
</project>``````
Posts: 10
Joined: Wed Sep 17, 2014 8:38 am

Post by WallyD444 » Tue Jul 14, 2015 11:26 am
Perfect, thank you!!