How does Opus expand variables?

I have the following small piece of code, where mfcfg.exe is a config program for a mirroring application that awaits options in the following format:
mfcfg.exe -add sourcedir mirrordir backupdir

[code]@set prg="C:\Program Files\MirrorFolder\mfcfg.exe"
@set s="{filepath}"
@set dm="{destpath}{file} Mirror"
@set db="{destpath}{file} Backup"

CreateFolder {$dm}
CreateFolder {$db}
{$prg} -add {$s} {$dm} {$db}[/code]

This is applied to folder dropmenu, so when I drop "Folder1" somewhere, this script should create folder "Folder1 Mirror" and "Folder1 Backup" there, and set up a mirroring job for the application.

Now, when I drop "Folder1" into "Folder2", "Folder1 Mirror" and "Folder1 Backup" folders are created in "Folder2" but the mirroring job is not. It was very strange, so I attached this to the end of the script to see what exactly happens there:

cmd /c echo {$prg} -add {$s} {$dm} {$db} > {destpath}aha.txt cmd /c echo {$s} >> {destpath}aha.txt cmd /c echo {$dm} >> {destpath}aha.txt cmd /c echo {$db} >> {destpath}aha.txt

The result was weird:

"C:\Program Files\MirrorFolder\mfcfg.exe" -add "{filepath}" "D:\[TEMP]\New Folder\Folder2\{file} Mirror" "D:\[TEMP]\New Folder\Folder2\{file} Backup" "{filepath}" "D:\[TEMP]\New Folder\Folder2\{file} Mirror" "D:\[TEMP]\New Folder\Folder2\{file} Backup"

That's not what I expected. Some parts of the variables did expand while others did not and this could be the reason why the mirroring job is not set but it does not explain those folder put into {$dm} and {$dm} being where they should be. They should not be created either.

Why did Opus not fully expand the variables?
How could the folders be created from not fully expanded variables?
Did Opus further expand them for CreateFolder?
If it did, why did it not for the mfcfg.exe?

Set the button's function type to MS-DOS Batch and it seems to work.

Not yet sure why it needs that, though.

Yes, it works now. Thanks for your quick reply.

BTW, in case you don't know already, you can add @runmode hide to the top of the command to prevent a DOS window from opening while it runs.

I was neither aware of that nor felt the need for hiding that window since it closes very quickly (actually, it just flashes), still, you are right. It looks much better with it hidden.

I just run into another problem. I decided to make this a bit more flexible and to offer the user the chance to change the name of the mirror folder before creating the job, so I replaced:

@set dm="{destpath}{file} Mirror"

with

@set dms="{destpath}{dlgstringS|Enter mirror folder|{file} Mirror}"

So far it's good, it pops up a dialog with the generated name, I get something like this:

But then something happens. I suppose the CreateFolder is suspended until the variable it requires gets set and it throws up another small window that obstructs the dialog window:

Is it possible to make the dialog remain on top?