How to write commands for macro creation properly?

Discuss macro implementations, ask for macro help (to share your creations, see User Creations, probably either Campaign Frameworks or Drop-in Resources).

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice

Post Reply
Forthfaran
Kobold
Posts: 2
Joined: Thu Jul 02, 2020 7:21 am

How to write commands for macro creation properly?

Post by Forthfaran »

I want to write a macro that creates a macro, which calls a macro.
The problem I encounter is the "@" character in the "call another macro" command:

Code: Select all

[h: macroProps=""]
[h: macroProps=setStrProp(macroProps, "autoexec", "true")]
[h: command=encode("[h, MACRO(\"test@Lib:Test\") ]")]
[h: createMacro("someName", decode(command), macroProps)]
This code should create a macro-button with the name "someName" and the code to call the macro "test" on the Lib:Test token.
But when I run this code, I get the error:

Code: Select all

unexpected char: '@' 
I tried to replace the @ with &#64, which gave the following error:

Code: Select all

expecting '&', found '#' 
I tried to replace the @ with @ (added the ";" ), which results in the following error:

Code: Select all

Error in the list. 
Command:  command=encode("[h, MACRO(\"test@Lib:Test\") ]")
I got rid of the encode(), and while it created the macro, the code of the created macro looked like this:

Code: Select all

 [h, MACRO( 
(rest of the code missing)

Now I am out of ideas :cry:
How can I write the code to make this work?

User avatar
aliasmask
RPTools Team
Posts: 9031
Joined: Tue Nov 10, 2009 6:11 pm
Location: California

Re: How to write commands for macro creation properly?

Post by aliasmask »

Try this:

Code: Select all

[h: macroProps=""]
[h: macroProps=setStrProp(macroProps, "autoexec", "true")]
[h: command='[h, MACRO("test@Lib:Test"):""]']
[h: createMacro("someName", command, macroProps)]

Forthfaran
Kobold
Posts: 2
Joined: Thu Jul 02, 2020 7:21 am

Re: How to write commands for macro creation properly?

Post by Forthfaran »

This worked, thank you :D

Post Reply

Return to “Macros”