mIRC Home    About    Download    Register    News    Help

Print Thread
Call scripts with another script? #191247 05/12/07 10:27 PM
Joined: Feb 2006
Posts: 97
O
ots654685 Offline OP
Babel fish
OP Offline
Babel fish
O
Joined: Feb 2006
Posts: 97
Is it possible to combine scripts with another script?
For example i have a function i use in other scripts, a search function and it's named search.mrc.

Can i just call that function/script in a other script or do i need to add the search function there also?

I'm not happy asking again for help but don't know if it's even possible can't find an example or documentation on how to do this.

I don't know how to show an example code of it but what i mean is this.

I have script.package.mrc that has a search function in it but the code for it is in search.mrc

search.mrc can be distributed on it's own and doesn't need script.package.mrc to work but script.package.mrc would like to use a function in search.mrc.

Can this be done?

I hope it's clear what i mean?


Re: Call scripts with another script? [Re: ots654685] #191248 05/12/07 10:47 PM
Joined: Dec 2002
Posts: 2,023
R
RoCk Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,023

Global aliases can be called from any other scripts, timers and the editbox. Here is an example of a global alias...

alias test echo -a test <-- global alias

Local aliases and only be called from within the same script. Here is an example of a local alias...

alias -l test echo -a test <-- local alias

Re: Call scripts with another script? [Re: RoCk] #191294 06/12/07 11:57 AM
Joined: Feb 2006
Posts: 97
O
ots654685 Offline OP
Babel fish
OP Offline
Babel fish
O
Joined: Feb 2006
Posts: 97
Ok thanks.
So if i wanna make use of other variables from other scripts I just need to make sure those scripts are loaded and for personal overview adding extra lines in main script that says it uses functions from .......mrc. Didn't knew it worked this way.

Did some object orientated programming in the past and maybe I mix things up because of that.

Re: Call scripts with another script? [Re: ots654685] #191297 06/12/07 12:10 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Originally Posted By: ots654685
I just need to make sure those scripts are loaded

These three identifiers might help you:

$script(scriptfilename) will be $true if some remote script with <scriptfilename> is currently loaded

$alias(aliasfilename) -analogical-

$isalias(aliasname) will be $true
- if there is an alias <aliasname> in an aliasfile
- if there is a global alias <aliasname> in a remote file
- if there is a local alias <aliasname> inside the same remote file

The $isalias().fname property might help you further to confirm it's "your" alias you are trying to call - but as long as you use *distinct* aliasnames, this should be no source of error anyway.

Many scripts ('full' scripts, differing from addons in this sense) use one ore more 'core' script files and access (call or trigger) these routines again and again in their 'satellite' files.

Last edited by Horstl; 06/12/07 12:32 PM.
Re: Call scripts with another script? [Re: ots654685] #191301 06/12/07 12:46 PM
Joined: Mar 2003
Posts: 612
B
billythekid Offline
Fjord artisan
Offline
Fjord artisan
B
Joined: Mar 2003
Posts: 612
if the variables are /set(i.e appear in the variable tab in the script editor) you can use them in any script. That's why it's a good idea to name your set variables something obviously peculiar to either yourself or the script you are working on for example i tend to do my vars something like %btk.varname. This helps stop another script from accidentally changing your variables.

Try to use local variables (set with /var not /set) wherever you won't need the var outside the calling routine.

btk


billythekid