TGC Codebase Backup



Mid() Function by Dave J

11th Sep 2004 20:08
Summary

Extracts text from a string at the given position and for the given length.



Description

Extracts text from a string at the given position and for the given length.

This very small function will extract some text from the string specified. It will start taking text out at the position given (0 being the start of the string, 1 being one char in, etc.) and for the specified length (1 being one character extracted, 2 being two chars extracted, etc.).

This function differs from DBP's default Mid$() function because DBP's command will only return one character from the middle of the string, this function can return as many as you like.

As usual with my submissions, a very basic example of how to use the function is given in the snippet. :)



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    Print Mid("Denise", 2, 3)

Wait Key
End

Function Mid(Str As String, Start As Integer, Length As Integer)
   S1$ = Right$(Str, (Len(Str) - Start))
   Result$ = Left$(S1$, Length)
EndFunction Result$