Problem running macro

Get help with the installation and running of the Zeus IDE. Please do not post bug reports or feature requests here. When in doubt post your question here.
Post Reply
Ciaran1
Posts: 7
Joined: Wed Jul 15, 2009 5:44 pm

Problem running macro

Post by Ciaran1 »

Hi,
I have the following lines in an extract of verilog code:

/////////////////
in1,
in2,
in3,
in4,
out
/////////////////

which I'm attempting to transform (using a multiple playbacks of recorded keystroke macro) into the following:

/////////////////
.in1(in1),
.in2(in2),
.in3(in3),
.in4(in4),
.out(out)
/////////////////

The macro I have recorded, to attempt to do this, is as follows:

function key_macro()
screen_update_disable()
MoveLineHome()
print(".")
MarkBlockSet()
MoveWordNext()
MarkBlockReset()
MarkCopyEx()
print("(")
MarkPasteEx()
print(")")
MoveLineDown()
screen_update_enable()
screen_update()
end

key_macro() -- run the macro


However, what I'm actually getting is:

/////////////////
.in1(in1),
.in2(),
.in3(),
.in4(),
.out()
/////////////////

I've tried changing the Ctrl+V keyboard shortcut from MarkPasteEx to MarkPasteSmart to MarkPaste, with differing results. However, none of these seem to give the desired result. I'd appreciate any insight on this.

Regards,
Ciaran.
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij »

This is very strange :?

When I run your macro:

Code: Select all

function key_macro()
    screen_update_disable()
    MoveLineHome()
    print(".")
    MarkBlockSet()
    MoveWordNext()
    MarkBlockReset()
    MarkCopyEx()
    print("(")
    MarkPasteEx()
    print(")")
    MoveLineDown()
    screen_update_enable()
    screen_update()
end

key_macro() -- run the macro
Using you input text text:

Code: Select all

/////////////////
in1,
in2,
in3,
in4,
out
/////////////////
I get your expected result:

Code: Select all

/////////////////
.in1(in1),
.in2(in2),
.in3(in3),
.in4(in4),
.out(out)
/////////////////
Which version of Zeus are you running :?:

I supect the problem might lie here:

Code: Select all

    MarkBlockSet()
    MoveWordNext()
    MarkBlockReset()
If the MoveWordNext does not move the cursor then nothing will get copied to the clipboard and hence nothing will get written by the MarkPasteEx function that follows.

One thing to remember is the MoveWordNext function defines word breaks using the delimiters defined in the document type, which could explain why I am not seeing the issue :?

To test this theory see if the macro works in a plain text (.txt) file.

One thing you could try is changing the order in which theings are done when the macro is recorded.

For example, rather than doing line home, print '.', mark copy, ... could you try line home, markcopy, line home, print '.', word next, paste... and see what that does?

Using this approach the following macro would have been recorded:

Code: Select all

function key_macro()
    screen_update_disable()
    MoveLineHome()
    MarkBlockSet()
    MoveWordNext()
    MarkBlockReset()
    MarkCopyEx()
    MoveLineHome()
    print(".")
    MoveWordNext()
    print("(")
    MarkPasteEx()
    print(")")
    MoveLineDown()
    screen_update_enable()
    screen_update()
end

key_macro() -- run the macro
Using you input text text:

Code: Select all

One other thing worth trying is binding the [i]MarkWordCurrent[/i] and [i]MoveWordEnd[/i] function to the keyboard key and using this keys as a replacement of the three lines of block marking code.

I have these functions bound to [i]Alt+H[/i] and [i]Alt+Left Arrow[/i] respectively and find these functions are invaluable when recording keyboard macros.

Using this approach the following macro would have been recorded:
[code]function key_macro()
    screen_update_disable()
    MoveLineHome()
    print(".")
    MarkWordCurrent()
    MarkCopyEx()
    MoveWordEnd()
    print("(")
    MarkPasteEx()
    print(")")
    MoveLineDown()
    screen_update_enable()
    screen_update()
end

key_macro() -- run the macro
Using you input text text:
[/code]
But what is really strange is your macro runs fine for me :?

Cheers Jussi
Ciaran1
Posts: 7
Joined: Wed Jul 15, 2009 5:44 pm

Post by Ciaran1 »

Hi Jussi,

Thanks for your prompt reply. I'm using Zeus 3.96s on Windows XP Pro.

When I tried the existing macro in a .txt file, as you suggested, it worked fine. The strange thing is, that when I then tried it in the .v file it worked fine then also :o. Now I can't get it to fail at all anymore.

As I had rebooted my machine prior to this, I can't say for definite whether the reason for the change in behavior was due to the reboot and re-launch of Zeus or due to the fact that I tried it in the .txt file, which somehow changed the behavior for other file types.

Thanks for your tips on the keystroke bindings. They look very useful.

Regards,
Ciaran.
Post Reply