Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Tips and tricks ➜ CallPlugin and multiple parameters.

CallPlugin and multiple parameters.

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Shadowfyr   USA  (1,791 posts)  Bio
Date Fri 20 Sep 2002 06:38 AM (UTC)

Amended on Fri 20 Sep 2002 06:44 AM (UTC) by Shadowfyr

Message
Well since there seems to be no real way to do this with the call. I have come up with this instead>

'==========================================================================================
'Latch for External plugin calls.
'
'Call syntax is "Name(Param,Param2,...)"
' i.e. CallPlugin "22ca9b6ff9d79f1a8e9f5895","CallLatch","Potion_Setcolor(title,#B0F080)"
'==========================================================================================
'NOTE: A call that uses () and (something) will both produce 1 parameter. Make sure you
'have error checking in the sub you call from here to deal with invalid values. ;)
'==========================================================================================
sub CallLatch (CallInf)
  dim temp,params,npar
  temp = split(CallInf, "(")    'Break things up at the first bracket, so temp(0) is the Sub and temp(1) is params.
  if ubound(temp) = 1 then      'If there are any parameters, remove the ) and split them into seperate bits.
    temp(1) = replace(temp(1),")","")
    params = split(temp(1),",")
  end if
  select case temp(0)   'Check against the Sub name to find a match.
    case "Potion_Setcolor"   ' Check against the first valid sub (this can be anything, but
                             ' is less confusing if it matches the real name).
      npar = 2   'How many parameters should there be?
      if ubound(params) <> npar - 1 then   'Test npar - 1 (arrays are 1 less than the 'real'
                                           'number of parameters. If it fails show an error.
        world.colournote "Red","Black", "Error: Invalid call to CallLatch in " & world.getpluginname & "."
        world.colournote "Red","Black", "Call was " & CallInf
        world.colournote "Red","Black", "  Error -- Invalid number of parameters. Should be " & npar & "."
        world.colournote "Red","Black", " "
      else   ' Everything looks OK, so lets make the real call here.
        call Potion_Setcolor(trim(params(0)),trim(params(1)))
      end if
    case else   'This is if we mis-spell are sub name in the other plugin/script or we
                'Tried to call a sub this plugin doesn't support.
      world.colournote "Red", "Black", "Error: Invalid call to CallLatch in " & world.getpluginname & "."
      world.colournote "Red", "Black", "Call was " & CallInf
      world.colournote "Red","Black", "  Error -- No such routine can be called."
      world.colournote "Red", "Black", " "
  end select 
end sub


This comes straight out of some upgrades I am making to a plugin and if used right will 'fake' a real call. Though it does require that you add your own test and error messages, etc. ;)
Top

Posted by Vaejor   (120 posts)  Bio
Date Reply #1 on Fri 20 Sep 2002 12:58 PM (UTC)
Message
Why not just send through an array as your single parameter?
Top

Posted by Shadowfyr   USA  (1,791 posts)  Bio
Date Reply #2 on Fri 20 Sep 2002 01:45 PM (UTC)
Message
I could have, but this way you 'seem' to be calling the exact routine that is used internally by the plugin. But also, according to Nick it is not technically allowed, since he is not sure if all script types support such an array.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


14,348 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.