Hi,
I was trying to work with strings and manipulating them using the string.sub, when I found that there is an issue with the sub command, now I am not sure if that is a Lua thing or a Corona thing.
Generally the syntax of sub is sub(theString, startPos, lengthOfCharacters)
I was stumped when I did not get the required results using
local i
for i=1,10 do --Assuming that the length of the string \*is\* 10 characters
local str = string.sub(theString, i ,1)
print ( str )
end
Now this was not working for me…any guesses at first look??
The issue is that the length is misleading, it requires the absolute positions, so sub is declared as
sub(theString, startPos, startPos+length)
so the same works if you use
local str = string.sub(theString,i,i)
I know it is silly but that’s how it is
cheers,
Jayant C Varma [import]uid: 3826 topic_id: 4675 reply_id: 304675[/import]