doskit for WindowsXP - 32bit versions - x86 architectures dutch, english ( experimental ), international ( experimental ).
A collection of tools and a functional library for people who like DOS script programming.
Debug builds should be run in VM
The macro:
Wikipedia wrote:A macro (from the Greek μακρό for "big" or "far") in computer science is a rule or pattern that specifies how a certain input sequence (often a sequence of characters) should be mapped to an output sequence (also often a sequence of characters) according to a defined procedure. The mapping process that instantiates (transforms) a macro into a specific output sequence is known as macro expansion.
The term is used to make available to the programmer, a sequence of computing instructions as a single program statement, making the programming task less tedious and less error-prone. (Thus, they are called "macros" because a big block of code can be expanded from a small sequence of characters). Macros often allow positional or keyword parameters that dictate what the conditional assembler program generates and have been used to create entire programs or program suites according to such variables as operating system, platform or other factors.
dbenham wrote:Here is a shocking demonstration of the performance benefits of the macros. I ran the original batch file at the top of this thread on a shared network drive at my workplace. Below is the timing portion of the output:Code: Select all
num2Hex macro time x 255 = 00:00:00.79
call time x 255 = 00:00:25.81
performance gain = 3267.09%
toLower macro time x 255 = 00:00:00.80
call time x 255 = 00:00:30.09
performance gain = 3761.25%
strLen macro time x 255 = 00:00:00.79
call time x 255 = 00:00:25.16
performance gain = 3184.81%
Average performance gain = 3404.38%
Speeds vary with memory usage.tooComplex wrote:TrimLH_ algorithm by aGerman, compressed to 415 bytes by tooComplex, definition stage:Memory expansion ( chcp 850, dutch ):Code: Select all
2>%_Dcon% ( %macroStart_% enableDelayedExpansion )
:: (
%= =%set ^"!$defines!=!vsDelim_!(^
!==^^^!^
%= =%set ?=^&set ?=^^^!%%~a^^^!^&^&(^
%= =%set f=^&set f=%%~b^|^|set f= %$n1c%
%= =%set/ac=4096^&!forC_! (1,1,12) do set f=^^^!f^^^!^^^!f^^^!%$n1c%
%= =%!forC_! (1,1,13) do if defined ? !forQ_! (^^^!c^^^!) do (^
%= =%if "^!?:~0,%%?^!"=="^!f:~-%%?^!" set ?=^^^!?:~%%?^^^!%$n1c%
%= =%if "^!?:~-%%?^!"=="^!f:~-%%?^!" set ?=^^^!?:~0,-%%?^^^!%$n1c%
%= =%set/ac/=2^
%= =%)%$n1c%
%= =%set %%~a=^^^!?^^^!^
%= =%)^
!==^^^!^
%= =%)else set *="
:: )
2>%_Dcon% %macroEnd%
%endlocalR_% (
%$%
)Command expansion:Code: Select all
trimLH_=for %? in (1,2) do if %?==2 (set ?=&for %? in (!*!) do set ?=!?!ª%?
if !?!.==. set ?="")&for /f "tokens=1-26delims=ª" %a in ("!?!") do (set ?=&set ?=!%~a!&&(set f=&set f=%~b||set f=
set/ac=4096&for /l %! in (1,1,12) do set f=!f!!f!
for /l %! in (1,1,13) do if defined ? for %? in (!c!) do (if "!?:~0,%?!"=="!f:~-%?!" set ?=!?:~%?!
if "!?:~-%?!"=="!f:~-%?!" set ?=!?:~0,-%?!
set/ac/=2)
set %~a=!?!))else set *=RunTime:Code: Select all
setlocal enableDelayedExpansion
:: (
set "$= C:\This work^^ s^!\This work^^ s^!.TMP "
::
echo. &( %necho#$_% $ ) &( %trimLH_% $ ) &( %necho#$_% $ )
set "$= TABBED "
::
echo. &( %necho#$_% $ ) &( %trimLH_% $, " " ) &( %necho#$_% $ )
:: )
endlocalCode: Select all
$: ' C:\This work^ s!\This work^ s!.TMP '
$: 'C:\This work^ s!\This work^ s!.TMP'
$: ' TABBED '
$: 'TABBED'
Post subject: Why does SET performance degrade as environment size grows?
http://www.dostips.com/forum/viewtopic.php?f=3&t=2597&p=11829&hilit=memory+linear#p11829
Objects and methods ( delayed ):
Code: Select all
setlocal enableDelayedExpansion &rem ( %debug.on_% "!$defines!" )
:: (
:: relative
( %oFile_% $, "This work^^ s^!.TMP", 1 ) ||( %assertFail_% )
::
( %$.touch% 1 ) ||( %assertFail_% )
( %$.move% "This_work^^ s^!.TMP", 1 ) ||( %assertFail_% )
( %$.link% 1 ) ||( %assertFail_% )
( %$.delete% 1 ) ||( %assertFail_% )
( %$.exist% ) &&( %assertFail_% )
:: UNC
( %oFile_% $, "\\192.168.1.10\ed-serv-0\This work^^ s^!.TMP", 1 ) ||( %assertFail_% )
::
( %$.touch% 1 ) ||( %assertFail_% )
( %$.move% "\\192.168.1.10\ed-serv-0\This_work^^ s^!.TMP", 1 ) ||( %assertFail_% )
( %$.link% 1 ) ||( %assertFail_% )
( %$.delete% 1 ) ||( %assertFail_% )
( %$.exist% ) &&( %assertFail_% )
:: absolute
( %oFile_% $, "C:\This work^^ s^!.TMP", 1 ) ||( %assertFail_% )
::
( %$.touch% 1 ) ||( %assertFail_% )
( %$.move% "C:\This_work^^ s^!.TMP", 1 ) ||( %assertFail_% )
( %$.link% 1 ) ||( %assertFail_% )
( %$.delete% 1 ) ||( %assertFail_% )
( %$.exist% ) &&( %assertFail_% )
:: )
endlocal
Code: Select all
» oFile_
« oFile_ [ok:loaded]
oFile_($;This work^ s!.TMP;1)
declareLE_($;file)
$fullPathFile: 'F:\ED\VIP\PROJ\dev\doskit\doskitXP32x86 v20121008\Hello world!\This work^ s!.TMP'
$fullPath: 'F:\ED\VIP\PROJ\dev\doskit\doskitXP32x86 v20121008\Hello world !'
$path: 'Hello world !'
$drive: 'F:'
$file: 'This work^ s!.TMP'
$fileName: 'This work^ s!'
$fileExtension: 'TMP'
$timeStamp: ''
$attributes: ''
$fileSize: ''
$method: 'exist,delete,touch,move,copy,link'
[ok:0]
[ok:0]
$.touch(F:\ED\VIP\PROJ\dev\doskit\doskitXP32x86 v20121008\Hello world !\This work^ s!.TMP;1;)
drive: 'F:'
path : 'ED\VIP\PROJ\dev\doskit\doskitXP32x86 v20121008\Hello world !'
file : 'This work^ s!.TMP'
[ok:0]
$.move(1)
← 'F:\ED\VIP\PROJ\dev\doskit\doskitXP32x86 v20121008\Hello world !\This work^s!.TMP'
→ 'F:\ED\VIP\PROJ\dev\doskit\doskitXP32x86 v20121008\Hello world !\This_work^s!.TMP'
[ok:0]
$.link(F:\ED\VIP\PROJ\dev\doskit\doskitXP32x86 v20121008\Hello world !\This_work^ s!.TMP;1)
$attributes: '--a------'
$timeStamp : '10/10/2012 00:46'
$fileSize : '0'
[ok:0]
$.delete(F:\ED\VIP\PROJ\dev\doskit\doskitXP32x86 v20121008\Hello world !\This_work^ s!.TMP;1)
[ok:0]
$.exist(F:\ED\VIP\PROJ\dev\doskit\doskitXP32x86 v20121008\Hello world !\This_work^ s!.TMP;0)
[error:17] object not physicall !
oFile_($;\\192.168.1.10\ed-serv-0\This work^ s!.TMP;1)
declareLE_($;file)
$fullPathFile: '\\192.168.1.10\ed-serv-0\This work^ s!.TMP'
$fullPath: '\\192.168.1.10\ed-serv-0'
$path: ''
$drive: '\\192.168.1.10\ed-serv-0'
$file: 'This work^ s!.TMP'
$fileName: 'This work^ s!'
$fileExtension: 'TMP'
$timeStamp: ''
$attributes: ''
$fileSize: ''
$method: 'exist,delete,touch,move,copy,link'
[ok:0]
[ok:0]
$.touch(\\192.168.1.10\ed-serv-0\This work^ s!.TMP;1;)
drive: '\\192.168.1.10\ed-serv-0'
path : ''
file : 'This work^ s!.TMP'
[ok:0]
$.move(1)
← '\\192.168.1.10\ed-serv-0\This work^ s!.TMP'
→ '\\192.168.1.10\ed-serv-0\This_work^ s!.TMP'
[ok:0]
$.link(\\192.168.1.10\ed-serv-0\This_work^ s!.TMP;1)
$attributes: '--a------'
$timeStamp : '10/10/2012 00:46'
$fileSize : '0'
[ok:0]
$.delete(\\192.168.1.10\ed-serv-0\This_work^ s!.TMP;1)
[ok:0]
$.exist(\\192.168.1.10\ed-serv-0\This_work^ s!.TMP;0)
[error:17] object not physicall !
oFile_($;C:\This work^ s!.TMP;1)
declareLE_($;file)
$fullPathFile: 'C:\This work^ s!.TMP'
$fullPath: 'C:'
$path: ''
$drive: 'C:'
$file: 'This work^ s!.TMP'
$fileName: 'This work^ s!'
$fileExtension: 'TMP'
$timeStamp: ''
$attributes: ''
$fileSize: ''
$method: 'exist,delete,touch,move,copy,link'
[ok:0]
[ok:0]
$.touch(C:\This work^ s!.TMP;1;)
drive: 'C:'
path : ''
file : 'This work^ s!.TMP'
[ok:0]
$.move(1)
← 'C:\This work^ s!.TMP'
→ 'C:\This_work^ s!.TMP'
[ok:0]
$.link(C:\This_work^ s!.TMP;1)
$attributes: '--a------'
$timeStamp : '09/10/2012 18:25'
$fileSize : '0'
[ok:0]
$.delete(C:\This_work^ s!.TMP;1)
[ok:0]
$.exist(C:\This_work^ s!.TMP;0)
[error:17] object not physicall !
endoftest Druk op een toets om door te gaan. . .
The new_ command can declare an object even if delayedExpansion is disabled.
Code: Select all
( %new_% oFile_, $, "This work^^ s^!.TMP", 1 )
Chaining &&redirection>
Code: Select all
>nul ( %$.move% "C:\" ) &&echo. succes ||echo. failed
directive = @
prefetch = macroName_ ( expects arguments )
postfetch = _macroName ( expects header )
bothfetch = _macroName_ ( expects both header & arguments )
regular escape = \
internal replace = ###
function scope = ?,º,¤,*, ~
global variable = §
variable global (preserved for user) = $
Variable names:
Prefetching your variable names with $ is not required, but advised. You may also use $ itself as variable name.
Forbidden variable names:
-forbidden chars: <SPACE>, <TAB>, <COMMA>, <%>, <?>, <^>, <!>, <">, <<> and <>>.
The delimiter:
Supports byRef and byVal.
Code: Select all
( %function_% $var, "!$var!", "%var%", "string with special characters "", %%, =, ?, ^^, ^!, \* and spaces." )
( %function_% byRef, byVal, byVal, byVal )
Using functions:
To get the usage information from a function, look it up in doskit.NFO. You can also call it with illegal parameters, it will then display detail information about it's usage. It's help is also displayed when it encounters any fatal error.
Code: Select all
My purpose.
My details.
use: ( %function_% #arg1, $arg2,"", $arg3,$var,"value" )
ret: void
err: 0 for succes, 1 for error
- #: expects a byVal.
- $: accepts both byRef or byVal.
- "": value is set to nothing if argument was not provided.
- "defaultValue": value is set to "defaultValue" if an argument was not provided.
#arg1 Expects a byVal, since no default value is set ( not even an empty string ) it becomes a required value that will signal illegal parameters if it's argument is missing.
$arg2 Accepts both byRef and byVal, if no value is provided it is set to empty string, making it an optional argument.
$arg3 will be set to the value the user provided, if no value is provided $arg3 will be set to $var, if $var is empty $arg3 will be set to "value".
Silent installation and running the demo:
Run 'silentSetup.CMD' or 'Hello world !.CMD' to install silently to these locations:
Code: Select all
reg: 'HKLM\SOFTWARE\ED'
dir: '!systemDrive!\ED\doskitXP32x86 !$version!'
Code: Select all
supported platforms: WindowsXP - 32bit versions - x86 architectures
language dependent : sometimes
languages : primary dutch, secondary english
programmer : tooComplex
special thanks to : admin, jeb, dBenham, aGerman from www.DOSTips.COM, the DOSTips team and members
includes :
-Hello World !.CMD My first 'Hello World !' doskit script
-doskit.CMD macro definition library
-function.CMD function support library
-7za.EXE extendControl archives win32 v4.65
-choice.COM controlInteractiveUser win32 XP Resource Kit
-cmdow.EXE controlGUI win32 NT4/2000/XP v1.4.3
-csound.COM controlInternalSpeaker win32 v2.2
-madplay.EXE controlExternalSpeaker win32 v0.15.2 (beta)
-mode.COM controlSystemDevices win32 XP Resource Kit
-stackey.COM addsKeyStuffin win32 v4.0
-resChangeCon.EXE Resolution Changer win32 v3.12
-regFind.EXE Registry Find Tool win32 v5.00.1980.1
-eval.EXE mathematical expression evaluator win32 v1.35.x86
-setACL.EXE adds dir/file, registry, service, win32 v2.0.3.0.x86
printer and Network share
AccesControlManagement
-madplay.MP3 by tooComplex
A hacking tool is NOT a virus.
For the Standard Shield provider (on-access scanning):
Left click the 'a' blue icon, click on the provider icon at left and then Customize.
Go to Advanced tab and click on Add button...
For the other providers (on-demand scanning):
Right click the 'a' blue icon, click Program Settings.
Go to Exclusions tab and click on Add button...
You can use wildcards like * and ?.
But be careful, you should 'exclude' that many files that let your system in danger.
The only thing the setup does, is proces the parameters from silentsetup or ask the user, where to install...
Then run Hello world !.CMD from there as demo.
You can download the project releases here
http://ed-dyreen.ddns.net/public/
more help: Batch "macros" with arguments
viewtopic.php?f=3&t=1827&start=0
Manual installation and uninstall :
Run 'setup.CMD' to install manually or uninstall.
Debug and feedback:
Code: Select all
( %Debug.on_% function )
Feel free to post ideas, suggestions, updates
Recently added/changed:
Code: Select all
07 Apr 2012 :§autoLogon_ ( #user,[$user.logon.name] )
02 Feb 2012 assign methods to objects using masked-macros instead of function calls ( improves object declaration times )
05 Dec 2011 add parsing support for arguments containing special character; [*]
05 Dec 2011 add parsing support for arguments containing special character; [?]
06 Dec 2011 disable both path and pathext to prevent autofilescan ( improves overall execution times )
08 Dec 2011 user request: allow doskit to load, even with missing source-files ( effectively removes all file checks ! )
12 Oct 2012 'iTime' intenationalization, 24hourFormat or PAMhourFormat defines objects.
Code: Select all
12 Oct 2012 intenationalization, OS Language defines constants.
2015 03 24: macros no longer need to be loaded ( now using a filePointer header ).
Code: Select all
05 Dec 2011 add parsing support for arguments containing special characters; [=,:]
@Admin as host
@jeb as contributor
-linefeed to macros, he made it possible to build macros in a convenient and organized way.
_http://www.dostips.com/forum/viewtopic.php?f=3&t=1827&start=0&hilit=linefeed+macro
-macros with parameters appended.
_http://www.dostips.com/forum/viewtopic.php?f=3&t=2518&start=15&hilit=parameters+appended
-88=16k memory combo (final, cannot be nested !)(debug).
_http://www.dostips.com/forum/viewtopic.php?f=3&t=2650&start=0&hilit=memory+combo
@dBenham as contributor
-pushing linefeeds and carriage returns over endlocal.
_http://www.dostips.com/forum/viewtopic.php?f=3&t=1839&hilit=return+any
@aGerman as contributor
-a working way to exit macros, setting the errorlevel and allowing both redirection and chaining simultaneously.
_http://www.dostips.com/forum/viewtopic.php?f=3&t=2465&start=0&hilit=chaining
@tooComplex as developer
-a working way of passing arguments and returning variables to macros.
_http://www.dostips.com/forum/viewtopic.php?f=3&t=1817&start=0
-a working way to allow redirection or chaining.
_http://www.dostips.com/forum/viewtopic.php?f=3&t=2465&start=0&hilit=chaining
-88=16k memory combo (final, cannot be nested !).
_http://www.dostips.com/forum/viewtopic.php?f=3&t=2650&start=0&hilit=memory+combo
-pushing linefeeds and carriage returns over endlocal (optimize).
_http://www.dostips.com/forum/viewtopic.php?f=3&t=1839&hilit=return+any
The experts team and members
For geeks:
Memory limitations:
Theoretical 8192, usable 8192-10, pushover endlocal practical 8192-+-1965 ( includes variable name ! )
Variable return limitations using endlocal_:
Code: Select all
( %endlocal_% var1, var2, etc.. )
-no ( $cr, $lf ).
Complex variable return limitations using advancedRF:
Code: Select all
set $rA=var1, var2, etc..
( %advancedRF% )
-supports ( $cr, $lf ).
The NFO file is included in the installer but can also be found inside the doskit folder after successful installation and loading of the demo 'Hello world !.CMD'
Thanks to Jeb and Aacini, the console will soon support colorText