Author Topic: Alias Function Resurrected (homemade)  (Read 3287 times)

Einlander

  • Newbie
  • *
  • Posts: 2
Alias Function Resurrected (homemade)
« on: August 15, 2008, 06:08:56 AM »
I was trying to make a control script that keeps track of who has access to all my scripts and i learned that the Aliases function dosent work anymore. So I set about recreating the function and came up with this:


Code: [Select]
Function OUTTEXT(OutgoingText)
    'IT WILL READ ALL INPUT THAT STARTS WITH "/" AS AN ALIAS
    if left(OutgoingText,1)="/" then
        Aliases readword(outgoingtext,1),_
        right(outgoingtext,len(outgoingtext)-len(readword(outgoingtext,1))),_
        CurrentServerNumber,_
        GetIdentifier("$currentchannel",CurrentServerNumber)
    end if
End Function

'I ADDED A PARAMETER TO THE ALIAS COMMAND "CHANNEL" SO YOU CAN DIRECT THE OUTPUT TO A 'CHANNEL
Function Aliases (Command, Parameters, ServerNumber,Channel)
    'Do your normal alias commands'
end function


'THIS HERE CODE IS MY PRIDE AND JOY. IT READS WHATEVER WORD THERE IS IN A STRING. WORDS MUST BE SEPREATED BY SPACES

Function readword(lineinput ,wordnum)
    'integers
    dim a ,i,lettercount ,lettercountcounter
    'strings
    dim char ,wrd
   
    for a=1 to wordnum
        char =""       
        wrd=""       
        for i = 1+lettercount to len(lineinput)                       
            char=mid(lineinput,i,1)
            wrd=wrd+char
            lettercountcounter=lettercountcounter+1
            if char =" " then exit for           
        next
        lettercount=lettercountcounter
    next
    readword=ltrim(rtrim(wrd))
end function


If you want to call an alias from another script all you have to do is:
Code: [Select]
outtext("/aliasyoucreated and what ever params you have")

hopefully you'll find this usefull

Einlander

  • Newbie
  • *
  • Posts: 2
Re: Alias Function Resurrected (homemade)
« Reply #1 on: August 16, 2008, 12:48:22 AM »
Heres a fixed version of the alias script. I found that with it enabled it ignored all commands that started with '/' to be ignored.

Code: [Select]
Function OUTTEXT(OutgoingText)
    'IT WILL READ ALL INPUT THAT STARTS WITH "/" AS AN ALIAS
    if left(OutgoingText,1)="/" then
        Aliases readword(outgoingtext,1),_
        right(outgoingtext,len(outgoingtext)-len(readword(outgoingtext,1))),_
        CurrentServerNumber,_
        GetIdentifier("$currentchannel",CurrentServerNumber)
    end if
    OUTTEXT=OutgoingText
End Function

'I ADDED A PARAMETER TO THE ALIAS COMMAND "CHANNEL" SO YOU CAN DIRECT THE OUTPUT TO A 'CHANNEL
Function Aliases (Command, Parameters, ServerNumber,Channel)
    'Do your normal alias commands'
end function


'THIS HERE CODE IS MY PRIDE AND JOY. IT READS WHATEVER WORD THERE IS IN A STRING. WORDS MUST BE SEPARATED BY SPACES

Function readword(lineinput ,wordnum)
    'integers
    dim a ,i,lettercount ,lettercountcounter
    'strings
    dim char ,wrd
   
    for a=1 to wordnum
        char =""       
        wrd=""       
        for i = 1+lettercount to len(lineinput)                       
            char=mid(lineinput,i,1)
            wrd=wrd+char
            lettercountcounter=lettercountcounter+1
            if char =" " then exit for           
        next
        lettercount=lettercountcounter
    next
    readword=ltrim(rtrim(wrd))
end function


If you want to call an alias from another script all you have to do is:
Code: [Select]
outtext("/aliasyoucreated and what ever params you have")