Einzelnen Beitrag anzeigen
Alt 11.10.2012, 23:15   #110
leecher
Moderator
POSO

E r g e b n i s / R e s u l t

The routine returns the position of the given occurence of a substring in a string.

B e s c h r e i b u n g / D e s c r i p t i o n

POSO returns the 1-based position of the [occur]th occurence of lookfor in string str.

S y n t a x

Code:
place = call("poso",lookfor,str,occur)
P a r a m e t e r

lookfor - The string to search
str - The string that gets searched
occur - Use the [occur]th occurence of lookfor in str

R e t u r n s

The 1-based position of lookfor in str or 0, if not found.

B e i s p i e l / E x a m p l e

Code:
attach "strfunc"
test = "harry~@jane~@Harryharryjennyharrynoodle~@"
put at 10,5 test 
lookfor = "harry" 
occur = 2 
place = call("poso",lookfor,test,occur)   ! will return 19 because function
put at 10,7 'The ', occur, ' occurrence of ', \\   ! is case sensitive 
            lookfor,  ' is at ', place   
lookfor = "~@" 
occur = 3 
place = call("poso",lookfor,test,occur)  ! will return 40  
put at 10,9 'The ', occur, ' occurrence of ', \\     
            lookfor,  ' is at ', place   
t = true
get t
put do clear screen 
detach"strfunc"
leecher ist offline   Mit Zitat antworten