Plex 2E

 View Only
  • 1.  Tip - Insert Subrountine

    Posted Jan 24, 2015 03:09 AM

    Finally got bored of writing subs

     

    So asked a colleague ( tack Jonny)  to create some vb for us

     

    option explicit
    dim WshShell
    
    
    Set WshShell = WScript.CreateObject("WScript.Shell")
    
    
    WshShell.SendKeys "+{HOME}"
    WScript.Sleep 10
    WshShell.SendKeys "^c"
    WScript.Sleep 10
    WshShell.SendKeys "Sub "
    WScript.Sleep 10
    WshShell.SendKeys "^v"
    WScript.Sleep 10
    WshShell.SendKeys "{ENTER}"
    WScript.Sleep 100
    
    
    WshShell.SendKeys "{+}{+}{+}Define  Field: FIELDS/{+}Subroutine"
    WScript.Sleep 10
    WshShell.SendKeys "{ENTER}"
    WScript.Sleep 100
    
    
    WshShell.SendKeys "Edit Point End ^v"
    WScript.Sleep 10
    WshShell.SendKeys "{ENTER}"
    WScript.Sleep 100
    
    
    WshShell.SendKeys "{+}If  Field: FIELDS/{+}Subroutine"
    WScript.Sleep 10
    WshShell.SendKeys "{ENTER}"
    WScript.Sleep 100
    
    
    WshShell.SendKeys "Edit Point ^v"
    WScript.Sleep 10
    WshShell.SendKeys "{ENTER}"
    WScript.Sleep 100
    
    
    WshShell.SendKeys "{TAB}"
    WScript.Sleep 10
    WshShell.SendKeys "{UP}"
    WScript.Sleep 10
    WshShell.SendKeys "{TAB}"
    WScript.Sleep 10
    WshShell.SendKeys "Edit Point Start ^v"
    WScript.Sleep 10
    WshShell.SendKeys "{ENTER}"
    WScript.Sleep 100
    
    
    WshShell.SendKeys "{TAB}"
    WScript.Sleep 10
    WshShell.SendKeys "{DOWN 5}"
    WScript.Sleep 10
    WshShell.SendKeys "{TAB}"
    WScript.Sleep 10
    WshShell.SendKeys "{+}{+}{+}Undefine  Field: FIELDS/{+}Subroutine"
    WScript.Sleep 10
    WshShell.SendKeys "{ENTER}"
    WScript.Sleep 100
    
    


  • 2.  Re: Tip - Insert Subrountine

    Posted Jan 28, 2015 12:53 PM

    Hi George,

     

    I did something similar using the AutoHotKey utility.  I created a script that prompts me for the subroutine name and then creates the code for me.  Very similar to your VB script.

     

    Here is the AutoHotKey script if anyone wants to use it.  It is setup to be triggered by the "Windows key + s".

     

     

    #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.

    SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.

    SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

     

    ; The following line defines the Hot key to use.  It is the Windows key + s.

    #s::

     

    InputBox, SubName, Subroutine Name, Enter a subroutine name

    if ErrorLevel

      return

    Else

      SendInput Sub %SubName%{Enter}

      SendInput {raw}+++Define FIELDS/+Subroutine

      SendInput {Enter}

      SendInput Edit Point Start %SubName%{Enter}

      SendInput {Tab}{Down}+{Tab}

      SendInput {raw}+If FIELDS/+Subroutine

      SendInput {Enter}{Tab}{Down}+{Tab}

      SendInput Edit Point End %SubName%{Enter}

      SendInput {Tab}{Down}+{Tab}

      SendInput {raw}+++UnDefine FIELDS/+Subroutine

      SendInput {Enter}{Tab}{Up}{Up}{Up}{Up}+{Tab}

      return

     

    Dean Eshleman,

    Everence Financial



  • 3.  Re: Tip - Insert Subrountine

    Posted Jan 29, 2015 03:28 AM

    Think Websydian guys use your method and I tried to get autohotkeys to work but with out the script such as yours I gave up after a very short time. Thanks for the script..opened my eyes to a whole new world of lazy

     

    And great way to support developers AD standards

     

    https://communities.ca.com/message/17891612#17891612

    Best Practice for subroutine structure?



  • 4.  Re: Tip - Insert Subrountine

    Posted Jan 29, 2015 01:25 PM

    That is an awesome tool! Only issue I have is the +++Undefine gets placed into the Line Editor and in order to add a new sub with the script you must remove that. Is there something we can add to the script to remove text from the line editor at the end?

     

     

     

    Thanks,

     

    Newbie Alex!



  • 5.  Re: Tip - Insert Subrountine

    Posted Jan 29, 2015 02:31 PM

    I found what I needed to do...

     

    I edited the second to last line 'SendInput {Enter}{Tab}{Up}{Up}{Up}{Up}+{Tab}" so it would actually go under the IF statement and not right above it. And then I added code to remove the last raw input, so here are these two lines.

     

     

      SendInput {Enter}{Tab}{Up}{Up}{Up}

     

      SendInput {Tab}+{Backspace}

     

      return



  • 6.  Re: Tip - Insert Subrountine

    Posted Jan 30, 2015 01:35 PM

    Hi Alex,

     

    Thanks for the enhancement.  Now it works even better.

     

    Dean Eshleman,

    Everence Financial