Page 1 of 1

Zeus VbScript and Variables

Posted: Mon Jun 25, 2007 11:51 pm
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

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

Posted: Tue Jun 26, 2007 4:33 pm
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