LastPos() bug

A forum dedicated to George scripting questions
Post Reply
User avatar
Mads Juul
Posts: 3992
Joined: 02 May 2007, 19:18
Location: Viborg,Denmark
Contact:

LastPos() bug

Post by Mads Juul »

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
Mads Juul
Storyboard Artist
blog: http://mjstoryboard.blogspot.dk/
Mail: mjstoryboard@gmail .com

Windows 10, 64 bit i7-4790 CPU 4.00 Hz,32 GB RAM, With TVP Animation 11 Pro (11.0.2-64bits)
2 Monitors 1920X1080 pixels + 1 Wacom Cintiq 21UX 2
User avatar
Mads Juul
Posts: 3992
Joined: 02 May 2007, 19:18
Location: Viborg,Denmark
Contact:

Re: LastPos() bug

Post by Mads Juul »

It's because the CHAR function cant take a position below 1
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
Mads Juul
Storyboard Artist
blog: http://mjstoryboard.blogspot.dk/
Mail: mjstoryboard@gmail .com

Windows 10, 64 bit i7-4790 CPU 4.00 Hz,32 GB RAM, With TVP Animation 11 Pro (11.0.2-64bits)
2 Monitors 1920X1080 pixels + 1 Wacom Cintiq 21UX 2
Post Reply