Subs

Posted by Rhinoa on Wed 30 Jan 2002 12:52 PM — 6 posts, 22,317 views.

United Kingdom #0
Hi :)
Is there a way to call subs into other subs..?
Like..:

Trigger:
Rhinoa says: Test
Label: Test
Sub: Test

Sub Test (strname, trig_line, arrWildCards)
if arrWildCards (1) = "Test" then
callsub Tester
end sub

Sub Tester (strname, trig_line, arrWildCards)
world.note "Hey, it worked"
end sub


I'm doing something that needs the programming like this, so I can't do it all in 1 sub..

Hope you can help! :)

~Rhinoa~
United Kingdom #1
Nevermind, I've got it now..
Seems the call bit was right, but I was doing something else wrong with the programming... and since I havn't used call before, I thought it was that, oh well..

~Rhinoa~
USA #2
Exactly what did you do to call another sub, I been looking for something like this for a little while, Could you outline how the call funtion works?

Thanks
Australia Forum Administrator #3
You could do it two ways:


Tester "blah", "", ""
call Tester ("blah", "", "")
USA #4
A while back I was looking for something like this.

Ok lets see if This resolves my question.

I have Trigger A. with say... 3 wildcards
Trigger a Runs sub 1

However, I want to run wildcard 2 through a different subroutine(why? I don't know but I want to make sure I understand if this is what i want it to do)

Ok so I run wildcard 2 through the other sub getting something new(what I don't know yet but I am sure I will think of something). So now I have wildcard 2 run through sub2 and I continue to run the original sub.

Why this is important to me I forget, but it is LOL

Does that sound like what its supposed to do?
Australia Forum Administrator #5
Yes you can do that. It might look like this:


sub do_wildcard_1 (strtext)
  world.note strtext  ' display it
end sub

sub do_wildcard_2 (strtext)
  world.note strtext  ' display it
end sub

sub do_wildcard_3 (strtext)
  world.note strtext  ' display it
end sub

Sub Trigger_sub (strname, trig_line, arrWildCards)
  do_wildcard_1 arrWildCards (1)
  do_wildcard_2 arrWildCards (2)
  do_wildcard_3 arrWildCards (3)
end sub


The above example only displays them, but shows the idea. You can route each wildcard through a different sub if you want to.

The trigger itself calls Trigger_sub.