Results 1 to 10 of 120

Thread: Subcode.vdm : The Macro Subroutines Project

Threaded View

  1. #1
    Senior Member
    Join Date
    Aug 2011
    Location
    British Columbia, Canada
    Posts
    383

    Subcode.vdm : The Macro Subroutines Project

    The Macro Subroutines Project

    The attached Subcode.vdm contains a number of useful subroutines that your macros can use. Put subcode.vdm in your USER_MACRO folder. To call one of these subroutines, use:

    call_file(r,"subcode.vdm","label")

    where r<>100 and label is the name of the subroutine

    There are several reasons behind the Macro Subroutine Project:

    - why write the same code more then once? Every time you do, there is the chance for typos and logic errors. Seems better to use (proven) code located in a subroutine library

    - if you only recently began Vedit macro programming, these subroutine will allow you to write macros that otherwise may be beyond your current skill level.

    - think of these subroutine as "commands created by users". Ever wished for a command that would eliminate writing many lines of code?

    To make these subroutine work, there are some register usage rules in both creating and using them:

    - Text & numeric registers between 10 and 19 are for Input values

    - Text & numeric registers between 20 and 29 are for Output values

    - Text & numeric registers between 30 and 49 are subroutine working registers. At the start of each subroutine, these registers are pushed to the stack, and are restored just before returning.

    The current subroutines :

    Clipreg puts the contents of t-reg 10 into the Windows clipboard.

    Getcal puts a calender for any month, year, into t-reg 23. calls getdate

    Getdate provides the full date (October 10, 2015), day of week (Monday), Month name (October), day of week number (Sunday=0), and number of days in month.

    Getfile asks user to select a file using Vedit internal command get_filename and returns component parts (path, filename, extension, etc)

    Onecol lets the user select an item from one column using the keyboard and puts item into t-reg 20. Line number of item selected is also returned. Provides ability to restrict user movement to a line range.

    Clipreg puts the contents of the Windows clipboard into t-reg 20

    Reset empties text registers and sets numeric registers to zero in range 10-29

    The subroutine are fully documented in the attached Subcode.txt.

    Please see the code to the included cal-demo.vdm which demonstrates the getcal and getdate subroutines. Consider how much code writing was saved by using these subroutines.

    (if you rather write your own code then use these subroutines, and you have the time and skill, more power to you!)

    It is my hope that one day Subcode.vdm will be to macro subroutine what Key-mac.lib is to keystroke macros. I hope other users will suggest additional subroutines, improve existing ones, and contribute their own subroutines.

    (WARNING: Massively Unwarranted Optimism Detected)

    Comments, code, suggestions, etc...

    Scott
    Attached Files Attached Files
    Using Vedit 6.21.3, (32 bit), dated 9/12/11 running on Windows 7 (64 bit).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts