Page 1 of 1

SafeAliases: Safely add/remove aliases in your macros.

Posted: Wed Sep 15, 2004 9:35 am
by Gameross

Code: Select all

| SafeAliases   09/15/04  08:20am   by: Gameross

| SafelyAddAlias  - Safely add aliases you think people will find useful to use your macro without destroying exiting aliases.
| Returns TRUE if your alias existed or is added. FALSE if alias with the same named exists and new alias not added.
| Ex:   /call SafeAddAlias "/test /echo test"  adds the alias /test.

Sub SafelyAddAlias(string safealias)

/if (!${Ini["..\macroquest.ini",Aliases].Find[${safealias.Arg[1, ]}]}) /squelch /alias ${safealias}
/return ${Ini["..\macroquest.ini",Aliases,${safealias.Arg[1, ]}].Equal[${safealias.Right[-${safealias.Find[ ]}]}]}

| SafelyRemoveAlias - Checks against alias's name and text for exact match.  Deletes if finds a matching alias.
| Returns TRUE if found and deleted.  For example, if you added the above /test alias and then later wanted to remove it.
| You'ld do  /call SafelyAddAlias "/test /echo test"   which would remove the alias /test.  But, if you did
| /call SafeltAddAlias "/test /echo test2"   the alias would not be removed.

Sub SafelyRemoveAlias(string safealias)
/declare exists bool ${Ini["..\macroquest.ini",Aliases,${safealias.Arg[1, ]}].Equal[${safealias.Right[-${safealias.Find[ ]}]}]}

/if (${exists}) /squelch /alias ${safealias.Arg[1, ]} delete
/return ${exists}