substring from string.find errors - bad argument #2 to 'sub'

I'm trying to get a simple substring happening of everything after ".." but it's throwing a runtime error saying that the output of string.find isn't a number. When I hard code the number it works fine.

local k = "com.mywebsite.my_product.001..MIRROR"

local dotPos = string.find(k,"..",1,true)
print(k)
print(dotPos)
print(type(dotPos))
print(string.sub(k,dosPos))

This outputs.....

com.mywebsite.my_product.001..MIRROR
25
number
Runtime error
.../Corona/screen1.lua:50: bad argument #2 to 'sub' (number expected, got nil)

I don't understand what is going wrong here. If I hard code string.sub(k,25) then it works.

1
2
3
4
5
local dotPos = string.find(k,"..",1,true)
print(k)
print(dotPos)
print(type(dotPos))
print(string.sub(k,dosPos))

**sigh** :)

views:1726 update:2011/10/5 21:23:48
corona forums © 2003-2011