Zeus VbScript and Variables

This forum allows you to share scripts with other Zeus users. Please do not post bug reports, feature requests or questions to this forum, but rather use it exclusively for posting scripts or for the discussion of scripts that have been posted.
Post Reply
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Zeus VbScript and Variables

Post by jussij »

This very simple VbScript macro will display display the current line and cursor position in the message bar.

It shows how to assign a VbScript local variable to the value return by a Zeus built-in function:

Code: Select all

Function key_macro()
    ' must have a document window
    if zeus.is_document() = 0 then Exit Function

    ' get current line position using the tag
    tag_line_num = zeus.macro_tag("$Line")

    ' get current line position
    line_num = zeus.get_line_pos()

    ' get current cursor position
    cursor_pos = zeus.get_cursor_pos()

    ' build up a message
    message = "Tag Line: " & tag_line_num & " Line: " & line_num & " Cursor: " & cursor_pos

    ' display message in status bar
    call zeus.message(message)
End Function

key_macro() 'run the macro
When run. the macro will display the current line and cursor position in the message section of the status bar and these details will match the line and cursor details shown on the right of the status bar.

Cheers Jussi
Ed Grossheim
Posts: 18
Joined: Mon Jun 25, 2007 6:26 pm

Using Jussi's answer: My Script to insert a Msg + Line No.

Post by Ed Grossheim »

6/26/2007 11:30:32 AM

My macro in vbs using Jussi's advice, which has the bonus of more info in the status box, to insert a Msgbox and Line number automatically in my Program via macro is as follows:

Code: Select all

Function key_macro() 
    call zeus.screen_update_disable 

    ' get current line position using the tag 
    tag_line_num = zeus.macro_tag("$Line") 

    ' get current line position 
    line_num = zeus.get_line_pos() 

    ' get current cursor position 
    cursor_pos = zeus.get_cursor_pos() 

    ' build up a message 
    message = "Tag Line: " & tag_line_num & " Line: " & line_num & " Cursor: " & cursor_pos 

    ' display message in status bar 
    call zeus.message(message) 
    call zeus.screen_update_enable 
    call zeus.screen_update

    call zeus.write("Msgbox " &Chr(34) &"This is line Number    "  &line_num & Chr(34) )

End Function 

key_macro() 'run the macro
Works very nicely for me.

--- Ed
Post Reply