Jump to content
xisto Community
Sign in to follow this  
imacul8

Mirc Identifiers In Vb6 Few token identifiers which work the same as mIRC functions do

Recommended Posts

If u have ever scripted in mIRC you would have surely come accross the token identifiers like $addtok $gettok, etc. Here is a little snippet u can add to your VB6 script to use these functions easily with the same format as the mirc commands. ie. $gettok(string,N,C)very easy to usehope it comes in use to someone, i use it a lot in my scripts :)Public Function AddTok(Text As String, Token, AscChar As Integer) As StringDim Tokens() As String, NumTokens As Integer, X As IntegerTokens = Split(Text, Chr(AscChar))NumTokens = UBound(Tokens) + 1For X = 1 To NumTokens If Tokens(X - 1) = Token Then GoTo ReturnLineNext XReDim Preserve Tokens(NumTokens)Tokens(NumTokens) = TokenReturnLine:AddTok = Join(Tokens, Chr(AscChar))End FunctionPublic Function InsTok(Text As String, Token, Insert As Integer, AscChar As Integer) As StringDim Tokens() As String, NumTokens As Integer, X As IntegerTokens = Split(Text, Chr(AscChar))NumTokens = UBound(Tokens) + 1ReDim Preserve Tokens(NumTokens)For X = NumTokens To Insert Step -1 Tokens(X) = Tokens(X - 1)Next XTokens(Insert - 1) = TokenInsTok = Join(Tokens, Chr(AscChar))End FunctionPublic Function NumTok(Text As String, AscChar As Integer) As IntegerDim Tokens() As StringTokens = Split(Text, Chr(AscChar))NumTok = UBound(Tokens) + 1End FunctionPublic Function GetTok(Text As String, Token As String, AscChar As Integer) As StringDim Tokens() As String, NumTokens As IntegerTokens = Split(Text, Chr(AscChar))NumTokens = UBound(Tokens) + 1If InStr(1, Token, "-") > 1 Then Dim X As Integer, Y As Integer, z As Integer, TokReturn As String X = Val(Mid(Token, 1, InStr(1, Token, "-") - 1) + 0) If InStr(1, Token, "-") = Len(Token) Then Y = 0 Else Y = Val(Mid(Token, InStr(1, Token, "-") + 1) + 0) End If If Y = 0 Then Y = NumTokens For z = X To Y If TokReturn = "" Then TokReturn = Tokens(z - 1) Else TokReturn = TokReturn & Chr(AscChar) & Tokens(z - 1) End If Next z GetTok = TokReturnElseIf Val(Token + 0) = 0 Then GetTok = NumTokensElseIf Val(Token + 0) <= NumTokens Then GetTok = Tokens(Token - 1)End IfEnd Function

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.