There is a bug in the included LastPos() function
if the character doesnt occur in the string a error will occur
pos = LastPos("mads","j")
will create an error
by the way i think these function would be nice to hace included in the core of the language so i didn't have to include them all the time.
and the TVPX filesdon't understand includes
-mads
LastPos() bug
Re: LastPos() bug
It's because the CHAR function cant take a position below 1
this should work
this should work
Code: Select all
FUNCTION LastPos(string,car)
pos = LEN(string)
run = 1
WHILE run >0
IF pos==0
run = 0
ELSE
IF (CMP(CHAR(string,pos),car) == 1)
run = 0
ELSE
pos = pos-1
END
END
END
IF pos == 0
pos = -1
END
RETURN pos
END