Applescript if statement : greater than and lower than Can I run an script if a variable is between 4 and 6 characters only ?

e.g

set serialNumber to ""
set theLength to (get length of (serialNumber as text))
if theLength is equal to 1 then
    set serialNumber to "No Serial"
else if theLength &gt; 4 and &lt; 6 then
    ##do this
else if theLength is greater than 6 then
    ## do nothing
end if


This is obviously not working :   else if theLength &gt; 4 and &lt; 6 then
Change:

else if theLength &gt; 4 and &lt; 6 then


To:

else if theLength &gt; 4 and theLength &lt; 6 then


Or, since you asked "Can I run a script if a variable is between 4 and 6 characters only?", which is equal to 5, you can also use:

else if theLength = 5 then


In place of:

else if theLength &gt; 4 and theLength &lt; 6 then


However, if testing between two numbers that are (one or) more then one, just use the variable twice in the test as shown above.