Done Add a .btm LIBRARY system

Oct 18, 2009
362
17
Add something similar to being able to load functions, but instead for accessing subroutine libraries:

Specify which libraries will be accessed.
LIB_NAME "Library Name" "Full path to library file, no wildcards"

Ex:
LIB_NAME "Date Routines" "C:\Program Files\JPSoft\TCC\Date_Routines_Lib.btm"
LIB_NAME "Name Routines" "C:\Program Files\JPSoft\TCC\Name_Formatting_Routines_Lib.btm"

Specify which routines in the library are available to this btm
LIB_DEF /"Library Name declared in a LIB_NAME" "Routine #1", "Routine #2", "Routine #5"

Ex:
LIB_DEF /"Date Routines" "CCYYMMDD_to_ISODATE", "ISODATE_to_YYMMDD"
LIB_DEF /"Name Routines" "Last_comma_First", "First_Mid_Last"

Call the pre-identified routine from the .btm
LIBRARY "Routine name" parm 1, parm 2

Ex:
LIBRARY Last_comma_First "Harry", "Johnson"
LIBRARY MMDDYY_to_ISODATE 111807

Error: Library Routine MMDDYY_to_ISODATE undefined
(Even if the "Date Routines" library does have that subrou, because it wasn't identified in LIB_DEF)
You would probably want a different term than "undefined".
 
Last edited:
Oct 18, 2009
362
17
Reasons for LIB_DEF are so if you have the same routine name in more than one library file there won't be confusion.
Also, having such a "declaration" up front will help the programmer see what is actually accessible.
 

samintz

Scott Mintz
May 20, 2008
1,503
16
Solon, OH, USA
Try these ALIASES and see how they work for you:
Code:
alias LIB_NAME=`set %@unquote[%1]=%2`
alias LIB_DEF=`set %@unquote[%2]=%[%@unquote[%1]] %@unquote[%3]`
alias LIBRARY=`if %[%1].==. (echoerr Library Routine %1 undefined) else (gosub %[%1] %*)`

[R:\] LIB_NAME "Date Routines" "C:\Program Files\JPSoft\TCC\Date_Routines_Lib.btm"
[R:\] set Date*
Date Routines="C:\Program Files\JPSoft\TCC\Date_Routines_Lib.btm"
[R:\] LIB_DEF "Date Routines" "CCYYMMDD_to_ISODATE", "ISODATE_to_YYMMDD"
[R:\] set CCYY*
CCYYMMDD_to_ISODATE="C:\Program Files\JPSoft\TCC\Date_Routines_Lib.btm" ISODATE_to_YYMMDD
[R:\] library CCYYMMDD_to_ISODATE 1 2 3 4
gosub "C:\Program Files\JPSoft\TCC\Date_Routines_Lib.btm" ISODATE_to_YYMMDD  1 2 3 4

[R:\] library MMDD_to_ISODATE 1 2 3 4
Library Routine MMDD_to_ISODATE undefined

In my example, I did an echo gosub instead of an actual gosub, since gosub is only valid inside a batch script.
 
Oct 18, 2009
362
17
I'm not looking to do it with aliases. I previously pointed out that an alias can be set up that LIBRARY is used as a substitute for GOSUB.

Modern programming languages routinely include some form of command such as IMPORT that makes the contents of some other file available, usually a routine library. I'm basically asking to include that type of functionality, like functions and aliases can be imported. I think it's best not to just block import an entire library file because it could get confusing to the person referencing the file and create conflicts. Requiring individual routines to be "declared" (e.g., LIB_DEF) would reduce confusion and avoid situations where multiple library files have a routine with the same name.

That's one reason I didn't include LIB_DEF /All as an option.
 

samintz

Scott Mintz
May 20, 2008
1,503
16
Solon, OH, USA
Since the aliases I created define environment variables, you could save them and restore them using SET /R. You could prepend "LIB_" or something similar to distinguish them from other variables. My point of the ALIAS's is that you can achieve what you wanted rather simply without the need for an entire management system.
 
Oct 18, 2009
362
17
I'm suggesting an added feature to the language, that will make the language more in line with other modern languages, not a custom work-around.

The problem with any custom work-around is different people set them up differently and there's no reference, which severely limits availability and usefulness of other people's code and libraries. The only way to encourage a standard approach is to have it as a language feature.
 
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
 
Oct 18, 2009
362
17
Joe,

I set this up as a new suggestion, since it's completely unrelated to a library addition.

It's set up as "MULTI-LINE IN-MEMORY FUNCTIONS", since that's really the request. It really wouldn't matter whether it's a start-up option or later. The same code that would be needed for multi-line in-memory functions later would be needed for them at startup.
 
Last edited:
Oct 18, 2009
362
17
The command description on page 410 of the manual should mention that TCC has a command-line switch that will prevent loading the default libraries.
 
Similar threads
Thread starter Title Forum Replies Date
Joe Caverly Add example .BTM code to TCC Debugger and CMDebug Suggestions 1
Joe Caverly Done Add ability to DEL Stream from SYMLINK Suggestions 2
Joe Caverly Add VHD to @drivetype Suggestions 1
R Option to add tcc to Bash profile Suggestions 1
R Add Custom Message to commands Suggestions 2
mfarah Declined Implement an "Add TCC to the task bar" in the TCMD installer. Suggestions 2
C Declined Add switch to MOVE to not make empty destination folders. (COPY's /F) Suggestions 4
M Add "ReleaseID" (aka version or build) to ver output Suggestions 2
R Declined In setup, add back/refresh buttons. Suggestions 1
D Done Suggestion: Add VIEW option to open in same position as current window Suggestions 0
D Done BDEBUGGER: add cmdline option to set a breakpoint at a given line Suggestions 0
D Done TCEdit and BDEBUGGER: add cmdline switch to jump to given line Suggestions 2
R Done Add "Evaluate Expression" to Right-Click Context Menu in Batch Debugger Suggestions 3
S Add support for Git auto-completion Suggestions 0
R Declined wish-list: add a command to copy a file to clipboard. Suggestions 17
R Declined Install option: Add File Explorer Run As Adminstrator option Suggestions 14
Dmitry L. Kobyakov Done Add the possibility to comment the ENDIFF Suggestions 11
Charles Dye Declined Windows functions and command: Add syntax to specify HWND directly Suggestions 0
Charles Dye Done @SNAPSHOT: Add option to capture the entire virtual screen Suggestions 0
R Done Add Libraries and Multi-line In-Memory functions to Features List on Website Suggestions 1
R Done Add to Pause Help text re indenting the prompt Suggestions 0
C Done Add ability for inline image files for sendmail or similar Suggestions 2
WinLanEm Add commands and functions Suggestions 11
rps Declined Add auto-load directives to tcmd.ini Suggestions 3
fromano Declined Add library functions to shralias saving feature Suggestions 12
Joe Caverly Add a "Snippet" Menu to CMDebug and TCC Debugger Suggestions 0
D Done Add the ability to control syntax coloring via an environment variable or some other way Suggestions 3
Alpengreis Done Add "Slow copy" (/WAIT) parameter to SYNC command Suggestions 1
Charles Dye Done MOUNTISO: Add support for VHD / VHDX files Suggestions 5
A Declined Take Command/Debugger as a Visual Studio 2017 add-in/extension Suggestions 4
rps Declined Add optional parameters to @search Suggestions 4
rps Done Add PDIR switches Suggestions 1
rps Declined ECHO -- Add spacing option Suggestions 2
vefatica Done Add log2 to @EVAL Suggestions 3
rps Done Add exclusion ranges to @files Suggestions 0
D Done Add VIEW option to open in same position as current window Suggestions 0
N Done Add display options to new HASH function Suggestions 1
rconn Add a parameter to dir command to handle zip files as folders Suggestions 1
rconn add support for batch file projects Suggestions 0
rconn Add support for backpipes Suggestions 0
rconn Add option to run programs Elevated from toolbar buttons Suggestions 0
rconn In the Help tab let the user add links either to files or web pages, with an icon & label. Suggestions 0
W Done Add colorize to tree command? Suggestions 0
Phileosophos Done Please add options for scrollback buffer searching Suggestions 24
G Declined Add option to turn on file name case sensitivity Suggestions 6
nickles Done Add a "Mark all threads read" button Suggestions 3
B Done Add New INI Directive To Specify WIPE Default Pass Count Suggestions 0
S Declined Add /W(ipe) option to several commands Suggestions 17
C TC drop-zone to add a tab Suggestions 0
W Done Add an option to control command line parsing Suggestions 7

Similar threads