Difference between revisions of "George Functions : Find"

From TVPaintWiki
Jump to: navigation, search
Line 12: Line 12:
 
   UNTIL ((i=i+1) > size)
 
   UNTIL ((i=i+1) > size)
 
   RETURN 0
 
   RETURN 0
END
+
END
  
  

Revision as of 10:55, 21 May 2010

FUNCTION Find(string,car,start)
 LOCAL i size
 i = start
 size = LEN(string)	
 IF ((start <= 0) || (start > size) || (CMP(car,"") == 1))
  RETURN -1
 END
 DO
  IF (CMP(CHAR(string,i),car) == 1)
   RETURN i
  END
 UNTIL ((i=i+1) > size)
 RETURN 0
END


Description

Find

Function: find a character into a string from a specified start position

Call: Find(string,car,start)

Arguments:

  • string = characters string
  • car = character to look for
  • start = start position in string

Return: position of character

0 if character does not exist into string -1 if invalid position (negative, null or higher)