Done UnLIBRARY command

May 20, 2008
473
2
Wildcards with /D are fine if you can guarantee locals do not conflict with globals. But, I would find requiring a prefix for everything to be quite the nuisance. For me, I would not likely need an UnLibrary if setlocal/endlocal covered that set as I could then do
Code:
setlocal
library /u /r %0
...
endlocal
Personally, I would prefer this support before the new command, though both have their uses.
 
May 20, 2008
11,400
99
Syracuse, NY, USA
It'll be interesting to see how library functions are used and how they evolve. They are a lot like aliases already. It they're made more like aliases (UNLIBRARY /R file, global/local, SETLOCAL, support from SHRALIAS) they will be nearly identical, with the only differences being the ease of making multi-line ones.
 
May 20, 2008
473
2
I kind of view them that way already, as an easier way of doing multi-line aliases. I don't view them as functions as all of my functions return a value. Library functions are more like aliases in that they are commands that do not return a value. The description wording is a bit confusing this way. Further, since my start BTM starts shralias if not running and loads an alias file, it was almost the same functionality to me as Library. The primary difference of library to me was the missing setlocal/endlocal support and being able to edit/reload a global set across sessions.
 
May 20, 2008
473
2
It's the pedant in me triggered by my programming background where functions have returned values and procedures or subroutines do not. In C/C++/C#, that would be the difference between void and non-void return values. In VB, that would be the difference between SUB and FUNCTION. I'm also thinking of how the FUNCTION command in TCC is used. In the example above, test doesn't actually return a string. Instead, the subroutine is setting a value that can later be checked. If the above were an actual function, doing echo %@test[] would be valid and not produce an error.

I often use the @echo combined with @execstr to have some of my aliases reusable as functions. My function file would have these defined as func=%@execstr[alias %1] so I could directly use the result of calling the alias within an expression or comparison. But, this doesn't make the original alias itself a function. With a FUNCTION defined function, you can echo %@func[] or if %@func[] GT 0 to directly get/use the returned value. With a LIBRARY defined function, you cannot use the resultant (singular?) value directly. You would need to wrap it in an actual function to retrieve that 'return' value before it could be used. Thus, doing echo %@libfunc[] would fail while doing echo %@execstr[libfunc] would work. But, as I said at the opening of this post, this is just pedantry on my part.

Along this semantic/pedantic vein, this gives me the idea of method, where the function, procedure, or subroutine is internal to a class or, in this case, the file. That may lead to defining library methods as
Code:
library.method {
   ...
}
That would then allow for the prefix usage of LIBRARY /D library.* to remove all methods defined in that file. This then has me thinking of combining array variables with library files to simulate C++ style classes in BTM language. In addition to containing the class member variables, the array could also contain the vtable of the related internal methods. But, this gets into a whole other topic.
 
May 20, 2008
11,400
99
Syracuse, NY, USA
Library functions are, like aliases, akin to commands. You have to wrap them in something to get a return value. Though it hasn't been mentioned, you can use @EXEC[] for that.
Code:
g:\tc22\library> library /f kk
kk {
set s=%@eval[%[$]]
quit %s
}

g:\tc22\library> echo %@exec[kk 3 + 5]
8
 
Oct 18, 2009
362
17
I agree that there should be a standard way to return a value. As I wrote in the original suggestion discussion about adding a LIBRARY command, there is always a problem with workarounds because different people will implement different workarounds.

There are some related issues, such as TCC user-defined functions use the recognizable syntax %@FunctionName[]

Perhaps a switch could be added to the FUNCTION command, maybe /U for "user library" or /V for "variable name", since /L is already used.

Something like:

A LIBRARY contains
Christmas{
Echo Merry Christmas

Set ReturnVariableName=December 25th
Set RussianOrthodoxXmas=January 12th
}

FUNCTION /V=ReturnVariableName XMas=Christmas

FUNCTION /V=RussianOrthodoxXmas ROXMas=Christmas

echo %@XMas[]
December 25th

echo %@ROXmas[]
January 12th

That would have the benefit that you could have multiple FUNCTIONS use the same LIBRARY function. For instance, you might have a Library STATE function that sets

Set State_uc=ALASKA
Set State_mc=Alaska
Set State_abbrv=AK

FUNCTION /V=State_uc STATE_UC= STATE Alaska
FUNCTION /V=State_mc STATE_PROPER= STATE Alaska
FUNCTION /V=State_abbrv STATE_USPS_ABBRV= STATE Alaska
 
Similar threads
Thread starter Title Forum Replies Date
D Done UNLIBRARY / Wildcarded removal of functions from library without errors Suggestions 2
Joe Caverly Done Specify which LIBRARY to run command from Suggestions 2
vefatica File name completion at the beginning of the command line Suggestions 6
L Done Suggestion for TCC 'ver' command Suggestions 8
JohnQSmith Done Modified last command prompt duration Suggestions 5
C Feature Request: Gain some elements of the XXCOPY feature set in COPY or a new "Mass-Copy" command Suggestions 0
D Done SHORTCUT command should accept unexpanded environment variables. Suggestions 0
mfarah Unix-like clear screen keystroke command. Suggestions 0
C Powershell ISE tabbed within Take Command Suggestions 0
D Command Input Feature Request Suggestions 0
R Done Putting command output into an array Suggestions 2
R Done Execute command while at a breakpoint Suggestions 4
R Done Allow single stepping within a command group Suggestions 5
R Declined wish-list: add a command to copy a file to clipboard. Suggestions 17
A Declined Navigation in Take Command Suggestions 4
x13 SORTARRAY command Suggestions 1
R ffind /= and command line Suggestions 0
A Declined Enhance OPTION command functionality Suggestions 2
R Done Command History Window: select more than one line. Suggestions 0
R Declined History: show in which directory a command has been typed. Suggestions 6
N Declined GUI for select command Suggestions 0
Charles Dye Done TCEDIT: Command-line option to print files Suggestions 2
Charles Dye Declined Windows functions and command: Add syntax to specify HWND directly Suggestions 0
vefatica Declined @@key alias at beginning of partial command line Suggestions 10
R Save and load a command dialog set and name it Suggestions 3
Alpengreis Done Add "Slow copy" (/WAIT) parameter to SYNC command Suggestions 1
L Completing the UnQLite command's option set Suggestions 0
joltcoder Done Support an "up" command to go to parent directory and "up3" to go up 3 directories, etc. Suggestions 4
M Declined Command line support for Virustotal Suggestions 0
A Declined Take Command/Debugger as a Visual Studio 2017 add-in/extension Suggestions 4
jaejunks Done Option for case-sensitive string comparison in IF command (for CMD compatibility) Suggestions 1
rps Done Log entry command Suggestions 3
rps Done Command and directory history pop-up additions Suggestions 2
rps Command History window options Suggestions 0
rps Declined Command output spacing options Suggestions 0
rps Done Command History edit additions Suggestions 0
J Done Set font in Take Command tabs in a .btm Suggestions 1
rconn Add a parameter to dir command to handle zip files as folders Suggestions 1
rconn Command Line constructor custom DIALOGs for batch files Suggestions 0
rconn A Command-line comparison Suggestions 0
rconn Done database access from command line Suggestions 0
W Done Add colorize to tree command? Suggestions 0
S Done Eject removable USB drives command Suggestions 2
Alpengreis Declined Any chance for quick help with all command-options? Suggestions 3
ehab aboudaya Done Shortcut Key to switch between current active tab & command input Suggestions 0
M Done Start command issue... Suggestions 6
mfarah Done Proposal: new PROMPT $i special command. Suggestions 2
S Done Enhanced TYPE command Suggestions 9
C Done DIFF command Suggestions 0
S Declined New command or new ACTIVATE option request Suggestions 5

Similar threads