mIRC Home    About    Download    Register    News    Help

Print Thread
Knowning what alias called another alias? #147800 24/04/06 07:36 AM
Joined: Nov 2004
Posts: 148
D
Dr_Brom_sung_ Offline OP
Vogon poet
OP Offline
Vogon poet
D
Joined: Nov 2004
Posts: 148
I'm writing a big script and I still have a lot of bugs.

I was wondering if I create an alias, and this alias is being called from another part of the code....

Is there a way of finding out which alias called it?? Or which line called it?
And if not, if I use "return", is there any way of knowing to which line it will come back? (Which is almost the same question)

This might help me fix the bugs, cause right now it becomes had to debug it.



Thanks.

Re: Knowning what alias called another alias? #147801 24/04/06 08:42 AM
Joined: Jan 2003
Posts: 1,063
D
Doqnach Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2003
Posts: 1,063
as far as I know there is no (regular scripting) identifier to check what alias called another.

best way to do this is to make a variable which holds the calling aliases name in it...

Code:
/alias1 {
  set -e %alias.name alias1
  ;do stuff
  alias3
}

/alias2 {
  set -e %alias.name alias2
  ;do stuff
  alias3
}

/alias3 {
  if (%alias.name == alias1) {
    echo -a Alias1
  }
  elseif (%alias.name == alias2) {
    echo -a Alias2
  }
  unset %alias.name
}


(the /set -e switch removes the var when mIRC exists and is v6.17+)


If it ain't broken, don't fix it!
Re: Knowning what alias called another alias? #147802 24/04/06 09:10 AM
Joined: Sep 2005
Posts: 116
I
Im2good4u Offline
Vogon poet
Offline
Vogon poet
I
Joined: Sep 2005
Posts: 116
an other way witch i prefer is
Code:
alias alias1 {
  ;do stuff
  $alias3(1)
}

alias alias2 {
  ;do stuff
  $alias3(2)
}

alias alias3 {
  echo 4 that alias that called this alias3 was alias $+ $1
  ;do stuff
}

this way u simpely give parameters to your alias call witch can be reado ut by $1 for first parameter $2 for 2nd and so on

Last edited by Im2good4u; 24/04/06 09:12 AM.
Re: Knowning what alias called another alias? #147803 24/04/06 09:43 AM
Joined: Nov 2004
Posts: 148
D
Dr_Brom_sung_ Offline OP
Vogon poet
OP Offline
Vogon poet
D
Joined: Nov 2004
Posts: 148
well, the problem is that I add data to a hash table, and one of the lines is not written write so the data that is being added is way wrong.

It can take me ages to look on all the lines... I wanted to create my own hadd alias:

alias hadd {
hadd $1-
write debug.txt $calling_alias hadd $1-
}

(When $calling_alias will be the indentifier I was hoping that exists)

This way I could then look at the debug.txt and find the corrupted lines easly and then find out from where they were sent.

With your ideas I still have to do a very hard work... I will practically need to edit or add a line to each of the lines that uses hadd (And there are a lot).


Well, I guess that I will have to do it that way by adding another debug line to each of the hadd lines... frown

Re: Knowning what alias called another alias? #147804 24/04/06 01:31 PM
Joined: May 2005
Posts: 449
bwr30060 Offline
Fjord artisan
Offline
Fjord artisan
Joined: May 2005
Posts: 449
I usually put alot of echoes in my code when I'm testing, which I know would still be alot of work if the script is large, but at least you can have it echo anything unique so you know where it is. Just a suggestion.

Re: Knowning what alias called another alias? #147805 25/04/06 01:43 AM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Code:
alias hadd_debug {
  write debug.txt $1 : $2 : HADD $3-
  hadd $3-
}


now search and replace all occrances of "HADD" with "HADD_DEBUG $script $scriptline"

* ensure your scripts folder/names do not have spaces in them.


Easy to do easy to reverse

Re: Knowning what alias called another alias? #147806 25/04/06 03:29 PM
Joined: Sep 2005
Posts: 116
I
Im2good4u Offline
Vogon poet
Offline
Vogon poet
I
Joined: Sep 2005
Posts: 116
may i dunno -l switch makes a comkmand just for your script so many u can overwrite the original hadd

Code:
alias -l hadd {
;hadd $1-
write debug.txt $calling_alias hadd $1-
}

Re: Knowning what alias called another alias? #147807 25/04/06 08:05 PM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
I know what the -l switch does, thats not what hes concerned with, he wants to be able to identify where he has called the alias from, and as far as I know there are no $identifiers for that. That is why i suggested using a search and replace on HADD, replacing it with a special alias and 2 identifiers, what are used by the alias to id where its called from.