Code archives/Algorithms/Delimeted string handler
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
OK, You've got a string with a few items in it and you want to find the 5th one. This function does it for you. entry(5,"Mr,Mrs,Dr,Ms,Miss",",") will return "Miss" Usage Entry ( [element number], [list$] , [Delimeter$] ) | |||||
; Entry function by Rob Farley 2004 ; rob@mentalillusion.co.uk Function Entry$(number,list$,delimeter$) n=1 count = 1 found = False start = 1 If number > 1 Repeat If Mid(list,n,1)=delimeter count = count + 1 If count = number found=True start = n + 1 Exit EndIf EndIf n=n+1 Until n >= Len(list) If found = False Then RuntimeError("List Element out of Range") EndIf Endof = Instr(list,delimeter,start) If endof = 0 Then endof = Len(list)+1 Return Mid(list,start,endof-start) End Function |
Comments
| ||
Neato function there :D useful! |
| ||
excellent |
| ||
Helped me out a lot! Cheers! |
Code Archives Forum