doskit XP/server2003 DEMO

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Ed Dyreen
Expert
Posts: 1527
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

doskit XP/server2003 DEMO

#1 Post by Ed Dyreen » 10 Nov 2018 18:59

Doskit is a batch script generator designed to allow doskit's functions to be used in and converted to standalone batch files. It's library has over 162 kernel functions and various optional classes.

The following code creates an object of class File. The first True argument tells the macro to halt if the path argument is malformed or undefined. The second to enable methods for this object. You can then address this object's methods and arguments directly as seen here:

Code: Select all

( %oFile_% $script, $script.fullPathFile, True, True )
( %$script.move% $newPath, True )
The True argument of the second command tells the move method to halt if any problem occurs, for example if the file does not exist. Most macros set an exitcode so you can implement conditions without checking errorlevels.

Code: Select all

( %$script.move% $newPath, False ) &&echo.succes ||(

	rem now what ?
)
You can figure out how to use a macro by looking at doskit.NFO which is created when you run doskit.

Code: Select all

kernel\IO\reg\key\regKeyRead_

Reads a registry key.

use: ( %regKeyRead_% '$vr,"%%~a"','$path,%%b,""','$key,%%c,""','$setsError,%%d,False' )
ret: $vr, $vr.path, $vr.key, $vr.type, $vr.data, d, t
err: 0 for succes, 4 for variable undefined, 31 for object not physical"
$vr is passed byValue this is because %~a is enclosed in doubleQuotes, it is also required because no optional value is defined like in the 2nd argument $path which %b parameter is not quoted. This means you can pas the argument quoted in which case it will be treated as a value or unquoted to pass it byReference. Not all functions support characters '?' and '*' byValue, in that case the only way to pass such arguments is byReference.

Open the file "Hello World !.CMD". You will see that there is some code inside. This is the sjablon you use to generate batch scripts.

In the beginning of the "Hello World !.CMD" file there are some global boolean switches. They control how your program will behave. Further down you will see several lines like this:

Code: Select all

rem set "$include=%$include% IO\net\*"%=		network share			=%
rem set "$include=%$include% var\*"%= 		convert ascii, dec, hex	=%
Commented by default, if you uncomment these lines these classes will be loaded.

For this program we don't need to uncomment anything since the only function we will be using for our first "Hello World !" program "n2echo_" is part of the kernel subclass "kernel\echo\" which functionality is always loaded because any member of class "kernel" is required for doskit to function properly.

when we scroll down we see a section called 'Main' containing the line:

Code: Select all

( %n2echo_% Hello World ^! )
Let's run our program by executing "Hello World !.CMD" or "tstHello World !.CMD". The latter is quite useful because it will keep the console window open in case of a crash so we can actually see what happened.

If the cache for a function is missing and needs to be created then doskit will first run all tests defined for that function if any, to ensure the function works as expected.

Then "doskit.NFO" is written. This file documents the functions that this configuration of doskit will support. However, many smaller functions are completely undocumented like the entire class 'echo' so you may still need to open up 'doskit.CMD' to figure out how a macro is used. Luckily nearly every definition comes with a test part that provides a working example/s of what a function does and how it is used.

When you run doskit it will scan the function 'Main' of the "Hello World !" script for any doskit macro or file reference and dump the 'Main' section in a new file called "byteCode.CMD".

Code: Select all

( %include_% "system\*" )
::
( %install_% "C:\ED\!$script.path!\" )
During conversion, doskit ignores all include_ macros so "system\*" will be completely ignored but not "system\install_" which will be included, thus filtering out unused functionality.

This is some of the code "bytecode.CMD" would include if "Hello World !.CMD" used doskit's "getDateFormat_" function.

Code: Select all

:: (getDateFormat_:disDelayed) '7964' bytes on file, '5510' bytes in memory.
:: (
%=	=%for %%# in ("") do set ^"getDateFormat_=for %%? in (1,2) do if %%?==2 (set ?=^&for %%? in (^!*^!) do set ?=^!?^!¦%%?%$n1c%
%=		=%if ^!?^!.==. set ?=^"^")^&for /F ^"tokens=1-26delims=¦^" %%a in (^"^!?^!^") do (for %%? in (1,2) do if %%?==2 (for %%? in (^!~^!) do (set/A$debug+=1,£e=0%$n1c%
%=		=%set $trace=%%~?%$n1c%
%=		=%set $debug[^!$debug^!]=%%~?%$n1c%
%=		=%set %%~?.p=^!*^!^&if ^!*:~^^,1^!==^^^^^^^! set %%~?.p=^!*:~1^!%$n1c%
%=		=%set $r=£e))else set ~=getDateFormat_%$n1c%
%=		=%for %%? in (1,2) do if %%?==2 (for /F ^"usebacktokens=1-2eol=¦delims=¦^" %%r in ('^!pathext^!¦^!path^!') do (set pathext=;^&set path=%$n1c%
%=		=%set ?=^!~:~1^!%$n1c%
%=		=%set ?=^!?:§=§0^!%$n1c%
%=		=%set ?=^!?:^"=^"^"^!%$n1c%
%=		=%set ^"?=^!?:^^=§9^!^"^&call set ^"?=%%^^?:^^^!=§3%%^"%$n1c%
%=		=%set ?=^!?:^"^"=^"^!%$n1c%
%=		=%set ?=^!?:\%$bs%*=\*^!%$n1c%
%=		=%set ?=^!?:\*=§4^!%$n1c%
%=		=%set ?=^!?:?=§6^!%$n1c%
%=		=%set ?=^!?:,,=§1,^"^",^!%$n1c%
%=		=%set ~=^&for %%? in (^!?^!) do set ^"?=%%?^"^&set ~=^!~^!,^!?^!^&if ^!?:~-1^!==' (set ó=^&set ô=^&set ò=%$n1c%
%=		=%set ?=^!~:~2,-1^!%$n1c%
%=		=%for %%? in (^!?^!) do set ~=%%?^&for %%? in (ó,ô,ò) do if ^!%%?^!.==. if defined ~ set %%?=^!~:§1=^!^&set ~=%$n1c%
%=		=%set ó=^!ó:§0=§^!%$n1c%
%=		=%set #=^&if defined ò set #=1%$n1c%
%=		=%for %%? in (ô,ò) do (set *=^&if ^!%%?:~^^,1^!==^^^" if ^!%%?:~-1^!==^^^" set *=1%$n1c%
%=		=%if ^!*^!==1 (set %%?=^!%%?:~1,-1^!%$n1c%
%=		=%if defined %%? set %%?=^!%%?:^"^"=^^^"^!)else set º=^!%%?:§0=§^!^&if defined ^!º^! (for %%@ in (^!º^!) do set %%?=^!%%@^!%$n1c%
%=		=%set %%?=^!%%?:§=§0^!)else set %%?=)%$n1c%
%=		=%if ^!ô^!.==. if defined ò (set ô=^!ò^!)else if ^!#^!.==. for %%? in (1,2) do if %%?==2 (call ^"^!$function.fullPathFile^!^" panic_ ^!~^!^^^!^&set/A£e=errorlevel%$n1c%
%=		=%exit ^!£e^!)else set ~=^"2^"%$n1c%
%=		=%if defined ô for %%? in (^"^!$lf^!^") do (set ô=^!ô:%%~?=§2^!%$n1c%
%=		=%set ô=^!ô:^"=^"^"^!%$n1c%
%=		=%set ^"ô=^!ô:^^=§9^!^"%$n1c%
%=		=%call set ^"ô=%%^^ô:^^^!=§3%%^"%$n1c%
%=		=%set ô=^!ô:\%$bs%*=\*^!%$n1c%
%=		=%set ô=^!ô:\*=§4^!%$n1c%
%=		=%set ô=^!ô:?=§6^!%$n1c%
%=		=%set ^"ô=^!ô:§9=^^^!^"%$n1c%
%=		=%call set ^"ô=%%^^ô:§3=^^^!%%^"%$n1c%
%=		=%set ô=^!ô:^"^"=^"^!%$n1c%
%=		=%set ô=^!ô:§2=%%~?^!%$n1c%
%=		=%set ô=^!ô:§4=\%$bs%*^!%$n1c%
%=		=%set ô=^!ô:§6=?^!%$n1c%
%=		=%set ô=^!ô:§0=§^!)%$n1c%
%=		=%if ^!$debug.sub^!==^!$trace^! echo(^>con^&^>con^<nul set/P= set '^!ó^!=^!ô^!'^^^^^^^!%$n1c%
%=		=%set ^!ó^!=^!ô^!)%$n1c%
%=		=%set pathext=%%r^&set path=%%s))else set ~=^^^^^^^!'r,%%a,^"0^"','$c,^"^!$scriptLocal.fullPath^!\dateFormat.CMD^"'%$n1c%
%=		=%if ^!§inline^!.==. set §inline=1^&echo(%$n1c%
%=		=%echo(^&^<nul set/P= ^!$trace^!^^(^!r^!^^)%$n1c%
%=		=%echo(^&^<nul set/P=  cache: '^!$c^!'%$n1c%
%=		=%if ^!r^!==1 (for %%? in (1,2) do if %%?==2 (set _=^"^!$function.fullPathFile^!^" callMacro_ ^!*:~1^!^&if ^!?^!.==. for %%? in (1,2) do if %%?==2 (for %%? in (^!*^!) do set ?=^&set ?=^!%%~?^!^&^&(set ?=^!?:^"=^"^"^!%$n1c%
%=		=%for /F ^"usebacktokens=1-2eol=¦delims=¦^" %%r in ('^!pathext^!¦^!path^!') do (set pathext=;^&set path=%$n1c%
%=		=%call set ^"?=%%^^?:^^^!=#^"#^"^^^!%%^"%$n1c%
%=		=%set pathext=%%r^&set path=%%s)%$n1c%
%=		=%set ^"?=^!?:^^=^^^^^!^"^&set ^"?=^!?:#^"#^"=^^^!^"%$n1c%
%=		=%set ?=^!?:^"^"=^"^!%$n1c%
%=		=%set %%~?=^!?^!%$n1c%
%=		=%set $r=^!$r^!,%%?))else set *=_%$n1c%
%=		=%for /F delims^^=^^ eol^^= %%r in (^"^!_^!^") do endlocal^&call %%r)else set ?=^!^&setlocal enableDelayedExpansion^&set *=^^^^^^^!fileDelete_,^"^!$c^!^")3^>nul^>^&3%$n1c%
%=		=%set $rs=^&call ^"^!$c^!^"2^>nul%$n1c%
%=		=%for %%? in (§dateFormat¦sShortDate%$n1c%
%=		=%§timeFormat¦sTimeFormat%$n1c%
%=		=%§dateSeparator¦sDate%$n1c%
%=		=%§timeSeparator¦sTime%$n1c%
%=		=%§timeDecimalSeparator¦sDecimal%$n1c%
%=		=%§timeIs24Format¦iTime) do for /F ^"usebacktokens=1-9eol=¦delims=¦^" %%r in ('%%?') do (if not exist ^!$c^! (for %%? in (1,2) do if %%?==2 (set _=^"^!$function.fullPathFile^!^" callMacro_ ^!*:~1^!^&if ^!?^!.==. for %%? in (1,2) do if %%?==2 (for %%? in (^!*^!) do set ?=^&set ?=^!%%~?^!^&^&(set ?=^!?:^"=^"^"^!%$n1c%
%=		=%for /F ^"usebacktokens=1-2eol=¦delims=¦^" %%r in ('^!pathext^!¦^!path^!') do (set pathext=;^&set path=%$n1c%
%=		=%call set ^"?=%%^^?:^^^!=#^"#^"^^^!%%^"%$n1c%
%=		=%set pathext=%%r^&set path=%%s)%$n1c%
%=		=%set ^"?=^!?:^^=^^^^^!^"^&set ^"?=^!?:#^"#^"=^^^!^"%$n1c%
%=		=%set ?=^!?:^"^"=^"^!%$n1c%
%=		=%set %%~?=^!?^!%$n1c%
%=		=%set $r=^!$r^!,%%?))else set *=_%$n1c%
%=		=%for /F delims^^=^^ eol^^= %%r in (^"^!_^!^") do endlocal^&call %%r)else set ?=^!^&setlocal enableDelayedExpansion^&set *=^^^^^^^!regKeyRead_,%%r,^"HKU\.DEFAULT\Control Panel\International^",^"%%s^",true)3^>nul^>^&3%$n1c%
%=		=%set $rs=^!$rs^!,%%r)%$n1c%
%=		=%for %%@ in (§dateFormat%$n1c%
%=		=%§timeFormat) do (set %%@=^!%%@:yyyy=y^!%$n1c%
%=		=%set %%@=^!%%@:mm=m^!%$n1c%
%=		=%set %%@=^!%%@:ss=s^!%$n1c%
%=		=%(for %%? in (1,2) do if %%?==2 (set _=^"^!$function.fullPathFile^!^" callMacro_ ^!*:~1^!^&if ^!?^!.==. for %%? in (1,2) do if %%?==2 (for %%? in (^!*^!) do set ?=^&set ?=^!%%~?^!^&^&(set ?=^!?:^"=^"^"^!%$n1c%
%=		=%for /F ^"usebacktokens=1-2eol=¦delims=¦^" %%r in ('^!pathext^!¦^!path^!') do (set pathext=;^&set path=%$n1c%
%=		=%call set ^"?=%%^^?:^^^!=#^"#^"^^^!%%^"%$n1c%
%=		=%set pathext=%%r^&set path=%%s)%$n1c%
%=		=%set ^"?=^!?:^^=^^^^^!^"^&set ^"?=^!?:#^"#^"=^^^!^"%$n1c%
%=		=%set ?=^!?:^"^"=^"^!%$n1c%
%=		=%set %%~?=^!?^!%$n1c%
%=		=%set $r=^!$r^!,%%?))else set *=_%$n1c%
%=		=%for /F delims^^=^^ eol^^= %%r in (^"^!_^!^") do endlocal^&call %%r)else set ?=^!^&setlocal enableDelayedExpansion^&set *=^^^^^^^!toLower_,%%@)2^>nul^>^&2)%$n1c%
%=		=%set $r=^!$rs^!%$n1c%
%=		=%(for %%@ in (^!$r^!) do (echo.set ^"%%@=^!%%@^!^"^>^&2%$n1c%
%=		=%echo(^&^<nul set/P=  %%@: '^!%%@^!'))2^>^!$c^!%$n1c%
%=		=%for %%? in (^!£e^!) do (echo(^&(if ^!£e:~^^,1^!==- (set ?=^!£e:~1^!)else set ?=^!£e^!%$n1c%
%=		=%for %%@ in (^"£error[^!?^!]^") do if ^!?^!==0 (^<nul set/P= [^!%%~@^!:^!£e^!])else ^<nul set/P= [error:^!£e^!] ^!%%~@^! ^^^^^^^!)^&for %%? in (1,2) do if %%?==2 (for /F ^"usebacktokens=1-4eol=¦delims=¦^" %%i in ('%%^!^"^"^!1¦%%^!^"^"^!2¦%%^!^"^"^!3¦%%^!^"^"^!~4') do for /F ^"usebacktokens=1-2eol=¦delims=¦^" %%r in ('^!pathext^!¦^!path^!') do (set pathext=;^&set path=%$n1c%
%=		=%set ¤=^&for %%? in (^!º^!) do if ^!¤^!.==. set/A¤=%%~?0/10^&if ^!¤^! NEQ 0 (call set º=%%º:*^!¤^!=%%)else set/A¤=1%$n1c%
%=		=%set _=^&for %%? in (^!º^!) do (set ?=^!%%~?^!^&if defined ? (set ?=^!?:%%=%%i^!%$n1c%
%=		=%for /F %%r in (^"^!$cr^! ^") do set ?=^!?:%%r=%%k^!%$n1c%
%=		=%set ?=^!?:^^^%$lf%%$lf%^%$lf%%$lf%=%%l^!%$n1c%
%=		=%set ?=^!?:%%=%%i^!)%$n1c%
%=		=%set _=^!_^!%%l%%~?#=^!?^!)%$n1c%
%=		=%set _=^!_:^"=%%j^!%$n1c%
%=		=%set ^"_=^!_:^^=%%9^!^"^&call set ^"_=%%^^_:^^^!=^"^"%%^"%$n1c%
%=		=%for /F delims^^= %%r in (^"^!_:~3^!^") do (for /L %%i in (1,1,^!¤^!) do endlocal%$n1c%
%=		=%set ?=^!^&setlocal enableDelayedExpansion%$n1c%
%=		=%set _=%%r%$n1c%
%=		=%call set ^"_=%%^^_:^"^"=^"^"^^^!%%^"^&if ^!?^!.==. (set ^"_=^!_:%%9=^^^^^!^"^&set ^"_=^!_:^"^"=^^^!^"%$n1c%
%=		=%set _=^!_:%%j=^^^"^!)else set ^"_=^!_:%%9=^^^!^"^&set _=^!_:^"^"=^!%$n1c%
%=		=%for %%@ in (^"^!$lf^!^") do set _=^!_:%%l=%%~@^!%$n1c%
%=		=%set _=^!_:%%i=%%^!%$n1c%
%=		=%for %%? in (^"^!$function.fullPathFile^!^") do for /F ^"tokens=1,*eol=#delims=#^" %%r in (^"^!_^!^") do (endlocal%$n1c%
%=		=%if ^!.==. (set _=%%s^!%$n1c%
%=		=%if defined _ (set _=^!_:%%l=^^^%$lf%%$lf%^%$lf%%$lf%^!%$n1c%
%=		=%for /F %%r in (^"^!$cr^! ^") do set _=^!_:%%k=%%r^!%$n1c%
%=		=%set _=^!_:%%i=%%^!)%$n1c%
%=		=%set ^"%%r=^!_:~1^!^"^!)else (set a=%%r^&set b%%s^&set c=%$n1c%
%=		=%call %%? §return.notDelayed)%$n1c%
%=		=%setlocal enableDelayedExpansion)%$n1c%
%=		=%endlocal)%$n1c%
%=		=%set pathext=%%r^&set path=%%s))else set º=$r,^!$r^!%$n1c%
%=		=%if %%~?==0 (call;)else if %%~?==1 (call)else cmd/Cexit %%?)) else setlocal enableDelayedExpansion^&set *=" !
:: )
This is the memory dump of getDateFormat_, but it is defined in "doskit.CMD".

Code: Select all

:: --------------------------------------------------------------------------------------------------------------------------
:dateTime\getDateFormat_
:: --------------------------------------------------------------------------------------------------------------------------
:: last updated       : 2018^11^20
:: support            : naDelayed, call-/file- macro
::
%for§_% ( %=	dependencies	=%

	"string\toLower_"

) do 	( %include_% "%%~§" )
::
( %includeCache_% "!$classpath!" ) &&goto :skip "()"
::
( %macroStart_% "!$classpath!", enableDelayedExpansion )
::
set ^"$usage.%$macro%=^
%=	=% Retrieve DateFormat from cache or invoke getDateFormat.%$n1c%

%=	=% use: ( %%getDateFormat_%% reInit,False )%$n1c%
%=	=% ret: §dateFormat, §timeFormat, §dateSeparator, §timeSeparator, §timeDecimalSeparator, §timeIs24Format%$n1c%
%=	=% err: 0 for succes, 1 for error"
:: (
%=	=%for %%# in ("") do set ^"%$macro%=!vsDelim_!(!setLocal_!!$macro!%$n1c%
%=		=%!paramL_!'r,%%a,"0"','$,$cache.fullPath','$c,"^!$cache.fullPath^!dateFormat.CMD"'%$n1c%
%=		=%!icho_! ^^^!$trace^^^!%e7%(^^^!r^^^!%e7%)%$n1c%
%$c1%
%=		=%!necho_!  cache: '^^^!$c^^^!'%$n1c%
%=		=%if ^^^!r^^^!==1 (!callMacro_!fileDelete_,$c)3^>nul^>^&3%$n1c%
%=		=%set $rs=^&call "^!$c^!"2^>nul%$n1c%
%=		=%!forQ_! (%$c1%
%$c1%
%=			=%§dateFormat¦sShortDate%$n1c%
%=			=%§timeFormat¦sTimeFormat%$n1c%
%=			=%§dateSeparator¦sDate%$n1c%
%=			=%§timeSeparator¦sTime%$n1c%
%=			=%§timeDecimalSeparator¦sDecimal%$n1c%
%=			=%§timeIs24Format¦iTime%$c1%
%$c1%
%=		=%) do !forR_! ('%%?') do (%$c1%
%$c1%
%=			=%if not exist ^^^!$c^^^! (%$c1%
%=				=%!callMacro_!regKeyRead_,%%r,"HKU\.DEFAULT\Control Panel\International","%%s","1"%$c1%
%=			=%)3^>nul^>^&3%$n1c%
%=			=%set $rs=^^^!$rs^^^!,%%r%$c1%
%=		=%)%$n1c%
%=		=%!for@_! (%$c1%
%$c1%
%=			=%§dateFormat%$n1c%
%=			=%§timeFormat%$c1%
%$c1%
%=		=%) do (%$c1%
%$c1%
%=			=%set %%@=^^^!%%@:yyyy=y^^^!%$n1c%
%=			=%set %%@=^^^!%%@:mm=m^^^!%$n1c%
%=			=%set %%@=^^^!%%@:ss=s^^^!%$n1c%
%=			=%(!callMacro_!toLower_,%%@)2^>nul^>^&2%$c1%
%$c1%
%=		=%)%$n1c%
%=		=%set $r=^^^!$rs^^^!%$n1c%
%=		=%(%$c1%
%=			=%!for@_! (^^^!$r^^^!) do (%$c1%
%=				=%echo.set "%%@=^!%%@^!"^>^&2%$n1c%
%=				=%!necho_!  %%@: '^^^!%%@^^^!'%$c1%
%=			=%)%$c1%
%=		=%)2^>^^^!$c^^^!%$n1c%
%$c1%
%=	=%!forQ_! (^^^!£e^^^!) do (%$c1%
%=		=%!exception.nPrintL!^&!endlocalL_!$r,^^^!$r^^^!%$n1c%
%=		=%!setExitCode!%$c1%
%=	=%))else setlocal enableDelayedExpansion^&set *="
:: )
( %macroEnd% )
::
( %filePutMacroBulk_% "!$classpath!" )
::
( %unitTest_% )
:: (
	setlocal
	:: (
		( %getDateFormat_% true )	||( %assertFail_% )
		( %getDateFormat_% ) 		||( %assertFail_% )
	:: )
	endlocal
:: )
:: --------------------------------------------------------------------------------------------------------------------------
::
goto :skip "()"
%endoftest%
:skip ()
exit /B %£e%
When writing macros, I have habits that do nothing but increase the size of the macro like forgetting to remove redundant linefeeds, spaces and tabs. Doskit scans for these types of inefficiencies during caching.

The cached macros are generated in such a way that they can be loaded from either delayed state and do not require to be pushed over endlocal which is the reason they are cached as separately loadable files for doskit and as an integral part of the future program.

When generation is complete you can rename "byteCode.CMD" to "Hello World !.CMD" and distribute it as a single script file solution.

For the moment the generation is fully automated by toByteCode_. This macro accepts a few parameters /supportParser /supportOldOS /supportDebug /clearCache. But these are for the moment also automated because the first two are not yet implemented and have no effect and the latter two are controlled by doskit. In the future /supportParser will allow to produce smaller programs if they do not have to process commandline arguments.

Towards the end of "Doskit.CMD" I dedicate a few sections on some of the most serious tricks I've seen around and things I always forget about. Documentation is brief.

Doskit XP/server2003 DOES NOT support win7/server2008 !

There is a minor difference with the 'set' command. In 7 'set/P=' without double quotes will eat spaces at the beginning of the line, this is a break from previous windows versions. Since 'set' is the most important command in dos, I predict this minor difference has big consequences that may cause all kinds of visual and file formatting issues.

Also doskit is completely unaware of 64bit capable OSes and it's binaries are all 32bit.

I try to write code that is international, still there are some functions that are language dependent and English is experimental.

DEMO VERSION
I am still working on "bytecode\*". This class contains the logic required to separate the source code from doskit so it can run as a standalone batch script. Once done I will upload a working version of doskit and will answer questions of some posters here in this topic. Picking out more difficult problems as the program stabilizes.

version 20181212 upcoming...
-In §byteAddPre_ fixed function pointers were not updated correctly to work with byteCode.
-In dateTime\timerStart_, dateTime\timerStop_ now use a default return $timer, so it is no longer necessary to pass it as argument if only using a single timer.
-In kernel\math\percent_ now returns percentage in variable given, not in default $percent variable.
-In kernel\IO\reg\key\regKeyRead_ now queries the default value with /ve if key missing, instead of enumerating all key values.
-In §filePutMacro fixed a bug causing a wrong logFile to be used.
-All functions using 'forP_' now support special characters '?', '*' and 'carriageReturn'. But the downside is that these functions no longer can force tokens to be read byValue using the "%%~a" technique which would trim doubleQuotes and add them again.

Latest is DEMO version 20181203 in attachment below.
-In §parser, now supports bytecode initialization.
-In §parser, fixed broken overflow detection and shorter algorithm.
-Excluded several tests, to allow to be run by 'the world' which would never pass them.
-Fixed: 'kernel\system\include_' would not link if directory did not exist.
-Loosened input format restrictions on several macros, "%%a" is now "%%~a" per default.
-In §parser, fixed broken call failure detection crash if input contained '<'.
-Doskit no longer runs in low priority so it suffers less when caching is happening in the background.
-In §toByteCode_ added optional arguments: /supportParser /supportOldOS /supportDebug /clearCache.
-In §byteAddPre_ fixed broken $lf, $n1c definition.
-In §byteAddPre_ added $c1 definition.
-In §byteAddPre_ added constants: ( False, True ).
-Depreciated function: byteAddMain_, byteAddPost, use toByteCode_.

Code: Select all

<!-- : As far as WSF is concerned, this is all just comment.
@echo off &cls &title %~n0
rem -------------------------------------------------------------------------------------------------------------------------
rem Hello world !                                                                                                           -
rem -------------------------------------------------------------------------------------------------------------------------
rem last updated: v2018^12^03
rem
rem	Greets the world
rem
rem 	programmer: tooComplex
rem
:: --------------------------------------------------------------------------------------------------------------------------
:: byteCode (
::
::   sourceFile          : W:\ED\VIP\PROJ\DEV\doskit\doskitXPserver2003 v20181203\Hello world !\Hello world !.CMD
::   sourceFunction      : §label0
:: )
:: --------------------------------------------------------------------------------------------------------------------------
:: --------------------------------------------------------------------------------------------------------------------------
:: doskit library (
::
::	supported platforms: winXP/server2003 - 32bit - x86
:: 	supported languages: dutch, english ( experimental ), international ( experimental )
:: 	programmer         : tooComplex
:: 	special thanks to  : Peter, jeb, dBenham, aGerman from www.DOSTips.COM, the DOSTips team and members.
:: )
:: --------------------------------------------------------------------------------------------------------------------------
:: --------------------------------------------------------------------------------------------------------------------------
:§parser_ ( '$function,"%%~a","§label0"', '$arguments,"%%~b*",""' )
:: --------------------------------------------------------------------------------------------------------------------------
:: last updated       : 2018^12^03
:: support            : naDelayed
:: languages          : N/A
::
:: Calls :§!$function! !$arguments!
::
:: - DOES NOT SUPPORT variableNames with delimiters that cannot be processed by 'if defined %variableName%' !
:: - Functions are onDelayed by parser.
::
:: (
rem 	( echo.&<nul set/P= inside §parser_^( %* ^) ) >con
<	:§return.notDelayed %( * )% <nul rem^ &if /I "%~1" NEQ "§return.notDelayed" goto :§return.notDelayed "()"
	:: (
		(	set "%a%=" &setlocal enableDelayedExpansion%=	var 'a' must be in code block to allow reset	=%

			rem ( %n2echo_% a=!a!_ )
			rem (  %necho_% b=!b!_ )
			rem (  %necho_% c=!c!_ )

			%endlocalRF_% (%=				var 'a' must be unset to detect overflow	=%

				endlocal

%=				=%set "%a%=%b%%c%"

				if "%b%" NEQ "" if not defined %a% call :§endSimple "§return.notDelayed: data overFlow: '%a%'"
			)
		)
	:: )
<	:§return.notDelayed %( * )% <nul rem^ &exit /B 0

	if not defined $kernel (%=							initialize doskit environment	=%

		for /F "tokens=1,2 delims==" %%a in (

			'set ^|findstr.EXE /BRIC:"[^\$]"'

		) do 	set "$sysVar.%%~a=%%~b"%=					backup caller's environment	=%

		( call :§init_ "( * )" ) &&(

			set /A $kernel = 1

		) ||	call :§endSimple "§parser_: 'call :§init_ ( * )' failed."
	)

	setlocal &set "$notDelayedFlag=!"%=				local, 		got caller's delayedState	=%
	:: (
		setlocal enableExtensions disableDelayedExpansion
		:: (
<			:§callSetVarSafe %( * )% <nul rem^ &set "ó=%pathext%" &set "ô=%path%" &set "pathext=;" &set "path="
			:: (
				(call set ?=%%^*)%= 					call prevents * to break code 	=%
%= 							$lf prevents 'input corrupt or incorrectly escaped' exception	=%
			:: )
			set "pathext=%ó%" &set "path=%ô%" &set "ó=" &set "ô="

			setlocal enableDelayedExpansion &set "$rA="%= 	function scope reached,	reset 8k returnables	=%
			:: (
				if "!?:~,1!" NEQ "§" (%=		no function marker,	not a doskit call 	=%

					set "?=§label0 !?!"
					set "?=!?:^=^^!"%= 		used call ?, 		double carets		=%
				)
			rem 	( %necho_% ?=!?! ) >con

				set "?=!?:"=""!^"%= 						disable	doubleQuotes	=%
				( %callSetVarSafe_% "?=%%^?:^!=#"#"^!%%" ) &set "?=!?:#"#"=^!"%=delay exclamation mark	=%
				(set "?=%?%" ! )%=		make carets inside doubleQuotes retract as expected	=%
				set "?=!?:""="!^"%= 						enable	doubleQuotes	=%
			rem	( %necho_% ?=!?! ) >con

				:: initialize function
				:: (
					set "?=!?! " &set "*=!?:* =!" &for /F "tokens=1 delims= " %%@ in (

						"!?!"

					) do 	( %setLocal_% "%%~@" )
				:: )

				:: call function, warn: call failures cannot be detected if £e is set to none 0 by caller.
				::
			rem	if defined $debug.sub ( %necho_%pre call :!$trace! !*! ^! ) >con
				:: (
					( call :!$trace! !*! ) ||if !£e! EQU 0 (%=	call failed with exitCode zero	=%

						call :§endSimple "call failed with exitCode zero." ^"§parser_: ^( :!$trace! !*! ^)^"
					)
				:: )
			rem	if defined $debug.sub ( %necho_%post call :!$trace! !*! ^! ) >con
			:: )
		:: )
	:: )

	:: 8k returnables maximum is 9.
	:: (
		>nul ( %advancedRF% )
	:: )

	rem ( %n2echo_% endlocal_ 3, $r, $rA, !$r! )
	rem ( %necho_% $rA=!$rA!_ ) &%forQ_% ( !$rA! ) do ( %necho_% %%~?=!%%~?!_ )
	::
	rem (%n2echo_% a1=!a1!_ )
	rem ( %necho_% b1=!b1!_ )
	rem ( %necho_% c1=!c1!_ )
	::
	rem (%n2echo_% a2=!a2!_ )
	rem ( %necho_% b2=!b2!_ )
	rem ( %necho_% c2=!c2!_ )
	::
	%endlocalRF_% (

		( %endlocal_% 3, $r, $rA, !$r! )%=				simple returns addressable range is 8k	=%

%=		=%set "%a1%=%b1%%c1%"!%=					8k returnables maximum is 9		=%
%=		=%set "%a2%=%b2%%c2%"!
%=		=%set "%a3%=%b3%%c3%"!
%=		=%set "%a4%=%b4%%c4%"!
%=		=%set "%a5%=%b5%%c5%"!
%=		=%set "%a6%=%b6%%c6%"!
%=		=%set "%a7%=%b7%%c7%"!
%=		=%set "%a8%=%b8%%c8%"!
%=		=%set "%a9%=%b9%%c9%"!

		if "%b1%" NEQ "" if not defined %a1% call :§endSimple "§parser_: data overFlow: '%a1%'"
		if "%b2%" NEQ "" if not defined %a2% call :§endSimple "§parser_: data overFlow: '%a2%'"
		if "%b3%" NEQ "" if not defined %a3% call :§endSimple "§parser_: data overFlow: '%a3%'"
		if "%b4%" NEQ "" if not defined %a4% call :§endSimple "§parser_: data overFlow: '%a4%'"
		if "%b5%" NEQ "" if not defined %a5% call :§endSimple "§parser_: data overFlow: '%a5%'"
		if "%b6%" NEQ "" if not defined %a6% call :§endSimple "§parser_: data overFlow: '%a6%'"
		if "%b7%" NEQ "" if not defined %a7% call :§endSimple "§parser_: data overFlow: '%a7%'"
		if "%b8%" NEQ "" if not defined %a8% call :§endSimple "§parser_: data overFlow: '%a8%'"
		if "%b9%" NEQ "" if not defined %a9% call :§endSimple "§parser_: data overFlow: '%a9%'"
	)
:: )
exit /B %£e%
:: --------------------------------------------------------------------------------------------------------------------------

:: --------------------------------------------------------------------------------------------------------------------------
:§init_ ( doskit environment ) [requires disableDelayedExpansion]
:: --------------------------------------------------------------------------------------------------------------------------
:: (
	:: $bs, ascii-0x08-08
	for /F "delims=#" %%? in (

		'"prompt #$H# &echo on &for %%? in (1) do rem"'

	) do 	set "$bs=%%?"
	::
	set "$bs=%$bs:~0,1%"

	:: $tab ascii-0x09
	for /F "skip=4tokens=2delims=pR " %%? in (

		'reg.EXE query hkcu\environment /v temp'

	) do 	set "$tab=%%?"

	:: $lf ascii-0x0A
(	set $lf=^
%=	! EMPTY LINE REQUIRED, DO NOT REMOVE !	=%
)
	:: $cr ascii-0x0D
	for /F %%? in (

		'copy /Z "%~f0" nul'

	 ) do 	set "$cr=%%?"

	:: $sub ascii-0x1A
	>nul copy /Z /A nul + nul "%temp%\$sub.TMP"
	:: (
		for /F "useback" %%? in (

			"%temp%\$sub.TMP"

		) do 	set "$sub=%%?"
	:: )
	>nul del /F /Q "%temp%\$sub.TMP"

	:: $esc ascii-0x1B-27
	for /F "delims=#" %%? in (

		'"prompt #$E# &echo on &for %%? in (1) do rem"'

	) do 	set "$esc=%%?"

	:: $c1, Line continuation [ 1 expansions ]											=
	set ^"$c1=%%~#^<nul ^^"

	:: $n1c, newline + continuation [ 1 expansions; 1 echo ]
	set ^"$n1c=^^^%$lf%%$lf%^%$lf%%$lf%^<nul ^^"

	:: constants
	set /A False = 0
	set /A True  = 1

	:: common errors
	set /A £e = 0
	::
	for /L %%? in (

		1, 1, 99

	) do 	set "£error[%%~?]=error unidentified"
	::
	set    "£error[0]=ok"                                             &::%=		range 0-99 doskit	=%
	set    "£error[1]=error unidentified"
	set    "£error[2]=argument not specified"
	set    "£error[3]=invalid input format"
	set    "£error[4]=variable undefined"
	set    "£error[5]=invalid argument V variable undefined"
	set    "£error[6]=undefined array $debug"
	set    "£error[7]=undefined array"
	set    "£error[8]=array at end, must undeclare manually"
	set    "£error[9]="
	set   "£error[10]=invalid fileName"
	set   "£error[11]=invalid fileExtension"
	set   "£error[12]=invalid drive"
	set   "£error[13]=invalid fullPath"
	set   "£error[14]=invalid fullPathFile"
	set   "£error[15]=invalid path"
	set   "£error[18]=invalid file"
	set   "£error[19]=insufficient privileges"
	set   "£error[20]=object delete failed"
	set   "£error[21]=object type invalid"
	set   "£error[22]=input type invalid"
	set   "£error[23]=object copy failed"
	set   "£error[24]=object creation failed"
	set   "£error[25]=stack overflow"
	set   "£error[26]=invalid share"
	set   "£error[28]=pattern not in file"
	set   "£error[29]=acces denied"
	set   "£error[30]=object not declared"
	set   "£error[31]=object not physicall"
	set   "£error[32]=object move failed"
	set   "£error[97]=only one instance can be active simultaneously"
	set   "£error[98]=violation of rule, restart without $jumpLabel"
	set   "£error[99]=a required resource is missing"

	set "£error[1128]=the image name is invalid"                      &::%=		range 1000-1100 taskKill	=%

	:: common variables
	set "$function.fullPathFile=%~f0"

:: --------------------------------------------------------------------------------------------------------------------------
echo(&<nul set/P= restoring memory...
:: --------------------------------------------------------------------------------------------------------------------------
:: (

:: (n2echo_:disDelayed) '26' bytes on file, '23' bytes in memory.
:: (
%=	=%for %%# in ("") do set ^"n2echo_=echo(^&echo(^&^<nul set/P=" !
:: )

:: (necho_:disDelayed) '19' bytes on file, '17' bytes in memory.
:: (
%=	=%for %%# in ("") do set ^"necho_=echo(^&^<nul set/P=" !
:: )

:: (endlocalRF_:disDelayed) '92' bytes on file, '77' bytes in memory.
:: (
%=	=%for %%# in ("") do set ^"endlocalRF_=for /F ^"useback tokens=1-3^" %%1 in ('%%,^^^",^!$cr^!,^^^"') do for %%4 in (^"^!$lf^!^") do" !
:: )

:: (callSetVarSafe_:disDelayed) '332' bytes on file, '262' bytes in memory.
:: (
%=	=%for %%# in ("") do set ^"callSetVarSafe_=for %%? in (1,2) do if %%?==2 (setlocal enableDelayedExpansion%$n1c%
%=		=%for /F ^"usebacktokens=1-3eol=¦delims=¦^" %%r in ('^!_^!¦^!pathext^!¦^!path^!') do (endlocal^&endlocal%$n1c%
%=		=%set pathext=;^&set path=%$n1c%
%=		=%call set %%r%$n1c%
%=		=%set pathext=%%s^&set path=%%t))else setlocal disableDelayedExpansion^&set _=" !
:: )

:: (setLocal_:disDelayed) '255' bytes on file, '180' bytes in memory.
:: (
%=	=%for %%# in ("") do set ^"setLocal_=for %%? in (1,2) do if %%?==2 (for %%? in (^!~^!) do (set/A$debug+=1,£e=0%$n1c%
%=		=%set $trace=%%~?%$n1c%
%=		=%set $debug[^!$debug^!]=%%~?%$n1c%
%=		=%set %%~?.p=^!*^!^&if ^!*:~^^,1^!==^^^^^^^! set %%~?.p=^!*:~1^!%$n1c%
%=		=%set $r=£e))else set ~=" !
:: )

:: (advancedRF:disDelayed) '1084' bytes on file, '738' bytes in memory.
:: (
%=	=%for %%# in ("") do set ^"advancedRF=(echo.^&if defined $notDelayedFlag (set/P= notDelayed^<nul)else set/P= delayed^<nul%$n1c%
%=		=%set *=^!$rA^!%$n1c%
%=		=%for /L %%i in (1,1,9) do (set ?=^&set ~=^&set _=^&for %%? in (^!*^!) do if ^!~^!.==. (set ~=%%~?%$n1c%
%=		=%set _=^!%%~?^!)else set ?=^!?^!,%%~?%$n1c%
%=		=%set *=^!?^!%$n1c%
%=		=%set ?1=^&set ?2=^&set ?=^&set ?=^!_^!^&^&(set ?1=^!?:~,4096^!^&set ?2=^!?:~4096^!^&for %%? in (1,2) do if defined ?%%~? (set ?=^!?%%~?^!%$n1c%
%=		=%set ?=^!?:%%=%%1^!%$n1c%
%=		=%set ^"?=^!?:^"=%%2^!^"%$n1c%
%=		=%for %%r in (^"^!$cr^!^") do set ?=^!?:%%~r=%%3^!%$n1c%
%=		=%for %%r in (^"^!$lf^!^") do set ?=^!?:%%~r=%%~4^!%$n1c%
%=		=%if ^!$notDelayedFlag^!.==. (for /F ^"usebacktokens=1-2eol=¦delims=¦^" %%r in ('^!pathext^!¦^!path^!') do (set pathext=;^&set path=%$n1c%
%=		=%call set ^"?=%%^^?:^^^!=^"^"^^^!%%^"^!%$n1c%
%=		=%set pathext=%%r^&set path=%%s)%$n1c%
%=		=%set ^"?=^!?:^^=^^^^^!^"^&set ^"?=^!?:^"^"=^^^!^")%$n1c%
%=		=%set ?%%~?=^!?^!))^|^|if ^!~^!.==. set ~=?%$n1c%
%=		=%set a%%i=^!~^!%$n1c%
%=		=%set b%%i=^!?1^!%$n1c%
%=		=%set c%%i=^!?2^!))" !
:: )

:: (forI_:disDelayed) '13' bytes on file, '12' bytes in memory.
:: (
%=	=%for %%# in ("") do set ^"forI_=for /L %%i in" !
:: )

:: (deq_:disDelayed) '7' bytes on file, '7' bytes in memory.
:: (
%=	=%for %%# in ("") do set ^"deq_=if 1==0" !
:: )

:: (forQ_:disDelayed) '10' bytes on file, '9' bytes in memory.
:: (
%=	=%for %%# in ("") do set ^"forQ_=for %%? in" !
:: )

:: (endlocal_:disDelayed) '1825' bytes on file, '1240' bytes in memory.
:: (
%=	=%for %%# in ("") do set ^"endlocal_=for %%? in (1,2) do if %%?==2 (for /F ^"usebacktokens=1-4eol=¦delims=¦^" %%i in ('%%^!^"^"^!1¦%%^!^"^"^!2¦%%^!^"^"^!3¦%%^!^"^"^!~4') do for /F ^"usebacktokens=1-2eol=¦delims=¦^" %%r in ('^!pathext^!¦^!path^!') do (set pathext=;^&set path=%$n1c%
%=		=%set ¤=^&for %%? in (^!º^!) do if ^!¤^!.==. set/A¤=%%~?0/10^&if ^!¤^! NEQ 0 (call set º=%%º:*^!¤^!=%%^&set/A¤+=1)else set/A¤=2%$n1c%
%=		=%set _=^&for %%? in (^!º^!) do (set ?=^!%%~?^!^&if defined ? (set ?=^!?:%%=%%i^!%$n1c%
%=		=%for /F %%r in (^"^!$cr^! ^") do set ?=^!?:%%r=%%k^!%$n1c%
%=		=%set ?=^!?:^^^%$lf%%$lf%^%$lf%%$lf%=%%l^!%$n1c%
%=		=%set ?=^!?:%%=%%i^!)%$n1c%
%=		=%set _=^!_^!%%l%%~?#=^!?^!)%$n1c%
%=		=%set _=^!_:^"=%%j^!%$n1c%
%=		=%set ^"_=^!_:^^=%%9^!^"^&call set ^"_=%%^^_:^^^!=^"^"%%^"%$n1c%
%=		=%for /F delims^^= %%r in (^"^!_:~3^!^") do (for /L %%i in (1,1,^!¤^!) do endlocal%$n1c%
%=		=%set ?=^!^&setlocal enableDelayedExpansion%$n1c%
%=		=%set _=%%r%$n1c%
%=		=%call set ^"_=%%^^_:^"^"=^"^"^^^!%%^"^&if ^!?^!.==. (set ^"_=^!_:%%9=^^^^^!^"^&set ^"_=^!_:^"^"=^^^!^"%$n1c%
%=		=%set _=^!_:%%j=^^^"^!)else set ^"_=^!_:%%9=^^^!^"^&set _=^!_:^"^"=^!%$n1c%
%=		=%for %%@ in (^"^!$lf^!^") do set _=^!_:%%l=%%~@^!%$n1c%
%=		=%set _=^!_:%%i=%%^!%$n1c%
%=		=%for %%? in (^"^!$function.fullPathFile^!^") do for /F ^"tokens=1,*eol=#delims=#^" %%r in (^"^!_^!^") do (endlocal%$n1c%
%=		=%if ^!.==. (set _=%%s^!%$n1c%
%=		=%if defined _ (set _=^!_:%%l=^^^%$lf%%$lf%^%$lf%%$lf%^!%$n1c%
%=		=%for /F %%r in (^"^!$cr^! ^") do set _=^!_:%%k=%%r^!%$n1c%
%=		=%set _=^!_:%%i=%%^!)%$n1c%
%=		=%set ^"%%r=^!_:~1^!^"^!)else (set a=%%r^&set b%%s^&set c=%$n1c%
%=		=%call %%? §return.notDelayed)%$n1c%
%=		=%setlocal enableDelayedExpansion)%$n1c%
%=		=%endlocal)%$n1c%
%=		=%set pathext=%%r^&set path=%%s))else setlocal enableDelayedExpansion^&set º=" !
:: )

:: (forP_:disDelayed) '2816' bytes on file, '1879' bytes in memory.
:: (
%=	=%for %%# in ("") do set ^"forP_=setlocal disableDelayedExpansion^&set $=^"^"^&(for /F usebackdelims^^=^^ eol^^= %%? in ('^!*^!') do set $=%%?)2^>nul^&(setlocal enableDelayedExpansion%$n1c%
%=		=%for /F ^"delims=^" %%? in (^"^!$^!^") do set $=%%?%$n1c%
%=		=%set ?=^&if defined $ (set $=^!$:^"=^"^"^!%$n1c%
%=		=%set ^"$=^!$:^^=^^^^^^^^^!^"%$n1c%
%=		=%for /F ^"usebacktokens=1-2eol=¦delims=¦^" %%r in ('^!pathext^!¦^!path^!') do (set pathext=;^&set path=%$n1c%
%=		=%call set ^"$=%%^^$:^^^!=#^"#^"^^^!%%^"^!%$n1c%
%=		=%set pathext=%%r^&set path=%%s)%$n1c%
%=		=%set ^"$=^!$:#^"#^"=^^^^^^^!^"^&set $=^!$:^"^"=^"^!%$n1c%
%=		=%for %%? in (^!$^!) do set ?=^!?^!¦%%?)%$n1c%
%=		=%if ^!?^!.==. set ?=^"^")^&for /F ^"tokens=1-26delims=¦^" %%a in (^"^!?^!^") do endlocal^&endlocal ^&for %%? in (1,2) do if %%?==2 (for /F ^"usebacktokens=1-2eol=¦delims=¦^" %%r in ('^!pathext^!¦^!path^!') do (set pathext=;^&set path=%$n1c%
%=		=%set ?=^!~:~1^!%$n1c%
%=		=%set ?=^!?:§=§0^!%$n1c%
%=		=%set ?=^!?:^"=^"^"^!%$n1c%
%=		=%set ^"?=^!?:^^=§9^!^"^&call set ^"?=%%^^?:^^^!=§3%%^"%$n1c%
%=		=%set ?=^!?:^"^"=^"^!%$n1c%
%=		=%set ?=^!?:\%$bs%*=\*^!%$n1c%
%=		=%set ?=^!?:\*=§4^!%$n1c%
%=		=%set ?=^!?:?=§6^!%$n1c%
%=		=%set ?=^!?:,,=§1,^"^",^!%$n1c%
%=		=%set ~=^&for %%? in (^!?^!) do set ^"?=%%?^"^&set ~=^!~^!,^!?^!^&if ^!?:~-1^!==' (set ó=^&set ô=^&set ò=%$n1c%
%=		=%set ?=^!~:~2,-1^!%$n1c%
%=		=%for %%? in (^!?^!) do set ~=%%?^&for %%? in (ó,ô,ò) do if ^!%%?^!.==. if defined ~ set %%?=^!~:§1=^!^&set ~=%$n1c%
%=		=%set ó=^!ó:§0=§^!%$n1c%
%=		=%set #=^&if defined ò set #=1%$n1c%
%=		=%for %%? in (ô,ò) do (set *=^&if ^!%%?:~^^,1^!==^^^" if ^!%%?:~-1^!==^^^" set *=1%$n1c%
%=		=%if ^!*^!==1 (set %%?=^!%%?:~1,-1^!%$n1c%
%=		=%if defined %%? set %%?=^!%%?:^"^"=^^^"^!)else set º=^!%%?:§0=§^!^&if defined ^!º^! (for %%@ in (^!º^!) do set %%?=^!%%@^!%$n1c%
%=		=%set %%?=^!%%?:§=§0^!)else set %%?=)%$n1c%
%=		=%if ^!ô^!.==. if defined ò (set ô=^!ò^!)else if ^!#^!.==. for %%? in (1,2) do if %%?==2 (call ^"^!$function.fullPathFile^!^" §panic_ ^!~^!^^^!^&set/A£e=errorlevel%$n1c%
%=		=%exit ^!£e^!)else set ~=^"2^"%$n1c%
%=		=%if defined ô for %%? in (^"^!$lf^!^") do (set ô=^!ô:%%~?=§2^!%$n1c%
%=		=%set ô=^!ô:^"=^"^"^!%$n1c%
%=		=%set ^"ô=^!ô:^^=§9^!^"%$n1c%
%=		=%call set ^"ô=%%^^ô:^^^!=§3%%^"%$n1c%
%=		=%set ô=^!ô:\%$bs%*=\*^!%$n1c%
%=		=%set ô=^!ô:\*=§4^!%$n1c%
%=		=%set ô=^!ô:?=§6^!%$n1c%
%=		=%set ^"ô=^!ô:§9=^^^!^"%$n1c%
%=		=%call set ^"ô=%%^^ô:§3=^^^!%%^"%$n1c%
%=		=%set ô=^!ô:^"^"=^"^!%$n1c%
%=		=%set ô=^!ô:§2=%%~?^!%$n1c%
%=		=%set ô=^!ô:§4=\%$bs%*^!%$n1c%
%=		=%set ô=^!ô:§6=?^!%$n1c%
%=		=%set ô=^!ô:§0=§^!)%$n1c%
%=		=%if ^!$debug.sub^!==^!$trace^! echo(^>con^&^>con^<nul set/P= set '^!ó^!=^!ô^!'^^^^^^^!%$n1c%
%=		=%set ^!ó^!=^!ô^!)%$n1c%
%=		=%set pathext=%%r^&set path=%%s))else set ~=^^^^^^^!" !
:: )

:: (endoftest:disDelayed) '52' bytes on file, '47' bytes in memory.
:: (
%=	=%for %%# in ("") do set ^"endoftest=(echo(^&^<nul set/P= endoftest ^&pause^&exit 0)^>con" !
:: )

:: (exception.nPrint:disDelayed) '271' bytes on file, '201' bytes in memory.
:: (
%=	=%for %%# in ("") do set ^"exception.nPrint=echo(^&(setlocal enableDelayedExpansion%$n1c%
%=		=%if ^!£e:~^^,1^!==- (set ?=^!£e:~1^!)else set ?=^!£e^!%$n1c%
%=		=%for %%? in (^"£error[^!?^!]^") do if ^!?^!==0 (^<nul set/P= [^!%%~?^!:^!£e^!])else ^<nul set/P= [error:^!£e^!] ^!%%~?^! ^^^^^^^!%$n1c%
%=		=%endlocal)" !
:: )

	<nul set/P=%$bs%%$bs% [done]
:: )
exit /B %£e%
:: --------------------------------------------------------------------------------------------------------------------------

:: --------------------------------------------------------------------------------------------------------------------------
:§label0 %( 'null,%%a,""' )%
:: --------------------------------------------------------------------------------------------------------------------------
:: last updated       : 2018^12^03
:: supported languages: N/A
::
::
::
rem ( %forP_% 'null,%%a,""' )
:: (
	:: Let's create some bytecode :)
	:: (


%endoftest%

:: Maybe cache usage.° and then join into usage.NFO


:: filegetmacro in the creation of objects is better replaced by callmacro.
:: this is possible through dependencies.
:: and allows bytecode to get a reference point.

:: if forP_ uses onDelim_ instead of _xsDelim_ then char '?' may be supported by functions.
:: eliminating the need for filelookup_ to pass those regular expressions as reference instead of value.

:: percent should return percentage in variable given,
:: not in default $percent variable.


:: I can use forT_ for the kernel includer instead of for§ because
:: forT_ is nasty and not very handy in macro's anyways.
:: all macros using forT_ will simply have to use another token.


:: I could design a macro _ultraDelim_ that replaces any * or ? wildcards by enumerating each char.
:: Then all macros using _ultraDelim_ can support regular expressions.
:: If this is fast enough then I may reconsider every advEnc /KCF situation.

:: Many macros that call their functions delay themselves
:: but if they just use call %%var%% this may not be necessary

:: bytecode should also support §EndOldOS.


:: if filewrite defaults to /noLock then it is fast enough to be used in include_

:: kernel\IO\reg\key\regKeyRead_ should query the default value with /ve if key missing.
:: not just enumerate them all.



	:: )

	( %n2echo_% All done )
:: )
::
::
set "$r=!$r!" &set "$rA=" &( %exception.nPrint% ) &exit /B !$err!
:: --------------------------------------------------------------------------------------------------------------------------
:: --------------------------------------------------------------------------------------------------------------------------
:§endSimple ( * )
:: --------------------------------------------------------------------------------------------------------------------------
:: last updated       : 2018^11^20
:: supported languages: N/A
:: (
	>con (echo.)
	:§endSimpleLoop "()"
	:: (
		>con (call echo.%%~1)
		::
		shift &if "%~1" NEQ "" goto :§endSimpleLoop "()"
	:: )
	>con ( <nul set/P"= " &pause )
:: )
exit 1
:: --------------------------------------------------------------------------------------------------------------------------
:skip () disable embedded WSF comment, must be last line in batch ! -->
Conversion took "00:33:38,230" in a VMWare6 1x3Ghz 512MB.

debug version 20181120 in attachment below.
-This is the first version that succeeds in converting the entire 'Hello World !' program. :mrgreen: The generated code itself does not work yet !, but does give a preview of what may be expected.
-Previously doskit was unable to detect dependencies in macros if they contained !callMacro_! * or !exeMacro_! * constructs. The reason was that * could be a macroName, a macroReference or a token and those constructs can be infinitely complex but the detection algorithm will always be limited. To overcome this, the include_ macro now stores macro dependencies in "*.include.CMD" files along the cache. This allows byteCode_ to detect these dependencies without needing to scan the contents of macros.
-Fixed a bug in class 'IO\file\fileLookUp_' where 8.3 matches would be returned when using regular expressions.
-'kernel\macro\filePutMacro_' no longer adds macros to the cachelist that are already on the list and §filePutMacro_ no longer removes them before caching is done. This prevents recaching of macros in situations where requests are coming in faster than the time it takes to process them.
-Faster detection algorithm; §macroGetdoskitFiles_, §macroGetdoskitFunctions_ and §macroGetdoskitMacros_
-'kernel\math\percent_' no longer locks its cachefiles before reading, this is faster.
-No stress, §filePutMacro now waits a while before it starts polling for requests.

Doskit has optional interfaces and classes for working with 7zip, choice, cmdow, csound, eval, madplay, mode, regfind, reschangecon, setACL and stackey which can be acquired by downloading the optional external binaries listed below. Some programs like cmdow may give you a false positive virus alert ( because it can hide windows ).

Please do report bugs and post all logs as attachment, if you fixed them yourself post your solutions here, so I may include them in a next release.

Thanks.
Attachments
Hello world !.7z
doskitXPserver2003 DEMO v20181203
(180.96 KiB) Downloaded 3 times
external binaries.7z.008.7z
remove .7z extension, added to allow upload
(212.61 KiB) Downloaded 5 times
external binaries.7z.007.7z
remove .7z extension, added to allow upload
(711.75 KiB) Downloaded 3 times
external binaries.7z.006.7z
remove .7z extension, added to allow upload
(711.75 KiB) Downloaded 3 times
external binaries.7z.005.7z
remove .7z extension, added to allow upload
(711.75 KiB) Downloaded 3 times
external binaries.7z.004.7z
remove .7z extension, added to allow upload
(711.75 KiB) Downloaded 3 times
external binaries.7z.003.7z
remove .7z extension, added to allow upload
(711.75 KiB) Downloaded 3 times
external binaries.7z.002.7z
remove .7z extension, added to allow upload
(711.75 KiB) Downloaded 3 times
external binaries.7z.001.7z
remove .7z extension, added to allow upload
(711.75 KiB) Downloaded 3 times
Hello world !.7z
debug version 20181120
(198.32 KiB) Downloaded 7 times

Sponge Belly
Posts: 195
Joined: 01 Oct 2012 13:32
Location: Ireland
Contact:

Re: doskit XP/server2003 TEASER

#2 Post by Sponge Belly » 21 Nov 2018 09:19

Hi Ed,

Doskit sounds amazing! 8)

I’d love to try it out, but I’m running Windows 7. :(

What difficulty does Doskit have with Windows 7?

- SB

Ed Dyreen
Expert
Posts: 1527
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: doskit XP/server2003 TEASER

#3 Post by Ed Dyreen » 21 Nov 2018 09:53

Sponge Belly wrote:
21 Nov 2018 09:19
Hi Ed,

Doskit sounds amazing! 8)

I’d love to try it out, but I’m running Windows 7. :(

What difficulty does Doskit have with Windows 7?

- SB
From what I've read there is a minor difference with the 'set' command. In 7 'set/P=' without double quotes will eat spaces at the beginning of the line, this is a break from previous windows versions. Since 'set' is the most important command in dos, I predict this minor difference has big consequences that may cause all kinds of visual and file formatting issues.

Also doskit is completely unaware of 64bit capable OSes and it's binaries are all 32bit.

Ed Dyreen
Expert
Posts: 1527
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: doskit XP/server2003 DEMO

#4 Post by Ed Dyreen » 10 Dec 2018 05:17

Finally a working demo !

I included "byteCode.CMD" and "tstbyteCode.CMD" so you do not have to run doskit to convert the "Hello World !" program.

Beyond this demo doskit is untested and you are on your own, njoy :)

Post Reply