Combining Strings

A forum for feature requests/discussions and user submitted patches that improve MQ2

Moderator: MacroQuest Developers

Ohmz
Developer
Developer
Posts: 97
Joined: Tue Feb 04, 2003 12:54 pm

Combining Strings

Post by Ohmz » Mon Oct 06, 2003 7:21 am

Due to a bug/feature in the old MQ script it was possible to combine and build strings:

Code: Select all

/varset l0 "a"
/varset l1 "b"
/varset l0 "$l0$l1"
/echo $l0
...
[MacroQuest] ab
unfortunately doing this now results in:

Code: Select all

/declare _word local
/declare _char local
/varset _word "a"
/varset _char "b"
/varset _word "@_word@_char"
/echo @_word
...
[MacroQuest] @_wordb
Because PMP parses from right to left, it essentially sets _word to a variable that doesn't exist (@_wordb), this then results in _word being set to a string constant containing a non-exitant variable as opposed to a derefrenced variable.

A temporary solution

Code: Select all

/declare _word local
/declare _char local
/varset _word "a"
/varset _char "b"
/varset _word "$mid(0,$strlen("@_word"),"@_word")@_char"
/echo @_word
...
[MacroQuest] ab
Perhaps a /stradd <variable> <addition> would be good?

Plazmic
The One
The One
Posts: 800
Joined: Fri Jun 14, 2002 12:31 am
Contact:

Post by Plazmic » Mon Oct 06, 2003 10:50 am

/varcat (?)
I'll write this after work...
- Plazmic