1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Multi-line in-memory functions

Discussion in 'Suggestions' started by Rick Reinckens, May 20, 2017.

Tags:
  1. Rick Reinckens

    Joined:
    Oct 18, 2009
    Messages:
    96
    Likes Received:
    4
    Copied from an off-topic comment regarding adding a library command.

    I would like to see something like BASH has, that is, the .bashrc file is loaded upon startup. The .bashrc file can contain multi-line functions, which would stay in memory like TCC plugins do.

    Or, like the Powershell Microsoft.PowerShell_profile.ps1 file, which does the same thing as .bashrc does.

    Ref: BASH Startup Scripts

    Joe

    #7 Joe Caverly, Yesterday at 6:07 AM
     
  2. Rick Reinckens

    Joined:
    Oct 18, 2009
    Messages:
    96
    Likes Received:
    4
    4Start/TCStart cannot have multiple-line functions. For example, in my PowerShell Profile I have;

    Code:
    function Get-ProgID
    {
      param ($filter = '.')
    
      $ClsIdPath = "REGISTRY::HKey_Classes_root\clsid\*\progid"
      dir $ClsIdPath |
       foreach {if ($_.name -match '\\ProgID$') { $_.GetValue("") }} |
         where {$_ -match $filter}
    }
    

    Get-ProgID is now a function that I can call from the command line. Example;

    Code:
    Get-ProgID VBScript
    
    Joe

    #9 Joe Caverly, Yesterday at 11:16 AM
     
  3. Rick Reinckens

    Joined:
    Oct 18, 2009
    Messages:
    96
    Likes Received:
    4
    I see two separate issues:

    1) TCC subroutines can return a value, so they can perform as functions.

    A function could be defined that calls a multi-line subroutine in a .btm and returns the value returned by that subroutine.

    2) That still requires repeatedly accessing a routine on disk.

    Keeping a multi-line function in memory would basically be equivalent to keeping a subroutine or an entire .btm in memory.
     
  4. Joe Caverly

    Joined:
    Aug 28, 2009
    Messages:
    659
    Likes Received:
    8
    If BASH and PowerShell can define multi-line functions in their startup files, and then keep them in memory, this should be possible with TCC.

    Rule of thumb:
    Ref: Functions, Aliases, and the Environment

    Joe
     
  5. Rick Reinckens

    Joined:
    Oct 18, 2009
    Messages:
    96
    Likes Received:
    4
    It certainly could be done. The question is whether Rex wants to add it. I get the impression it would require some major reworking.

    Another consideration is the increasing use of SSD's. I realize that TCC tends to be used on servers and those tend to still use hard disks. Also, although SSD's can have read/write speeds in the range of 500MB/s, memory access (e.g., ramdisk) can easily be 4-6GB/s. And my understanding is that on its own Windows will cache in memory relatively small files that are accessed frequently.

    But I think in most cases people would be fine with "repeated disk acccess" at 500MB/s. So a question is whether Rex wants to make a major change that will probably be almost moot in a few years.
     

Share This Page