Done Add a .btm LIBRARY system

Oct 18, 2009
214
8
#1
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
214
8
#2
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,313
11
Solon, OH, USA
#3
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
214
8
#4
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,313
11
Solon, OH, USA
#5
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
214
8
#6
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.
 
#9
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
214
8
#10
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: