byteCode, a java concept ?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

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

byteCode, a java concept ?

#1 Post by Ed Dyreen » 24 Dec 2013 00:14

[edit: 24 Dec 2013 23:50]
Once I posted a library, a collection of batch functions and macros and some tools for convenient batch scripting. This allows me to write less error prone scripts much faster due to the high abstraction a library provides.

Unfortunately the more macro's included in a library the longer it takes to initialize. One way to reduce load and optimize performance is to only include those macro's that will be used. What if this process could be automated ? What if I could write a batch file using functions stored in other files and then having it processed in some way so it can run independently from its library ? Having a byteFile pumped out automatically which would have higher performance and smaller file-size than the original.

The script I am writing may use this particular library function;

Code: Select all

::--------------------------------------------------------------------------------------------------------------------------
set "$defines=toParams_"
::--------------------------------------------------------------------------------------------------------------------------
:: last updated       : 2012^11^14
:: support            : naDelayed, delayedChars, related chaining
::
:: Processes formatted arguments.
::
:: -Value is assigned to argName, if value is null then argName is set true.
::
:: -Similar to how microsoft programs parse commandline arguments,
::  arguments are only valid if they start with a slash and are combined if they end with a colon,
::  other cases are ignored eg; /argName: "value" /boolArg
::
:: -Unless enclosed in double quotes, the default delimiters apply.
::
:: -Double quotes inside values which are unevenly distributed need to be doubled, eg;
::  correct; /argName: "val""ue", wrong; /argName: "val"ue"
::
:: $par0: original parameters passed to the function.
:: $par : number of arguments passed
:: $parN: where n is a number from 1 to number of arguments passed, the actual argument.
:: $p   : the value of the arguments passed ( booleans excluded ).
::
set ^"$usage.%$defines%=^
%=     =% use: ( %%toParams_%% #etc.. )%$n1c%
%=     =% ret: string $p, array $par, all variables as boolean or string%$n1c%
%=     =% err: unaffected, panic otherwise"
::
2>%_Dcon% ( %macroStart_% enableDelayedExpansion )
:: (
%=     =%set ^"!$defines!=!forQ_! (1,2) do if %%?==2 (!setLocal_!!$defines!%$n1c%
%=          =%!necho_! !$defines!%e7%(^^^!_^^^!%e7%)%$n1c%
!==^^^!^
%=          =%!forÇ_! (1,1,^^^!$par^^^!) do set $par%%ç=%$n1c%
%=          =%!reDelayLH_!_%$n1c%
%=          =%set $par=^&set $par0=^&!forQ_! (^
%=               =% ^^^!_^^^!^
%=          =%) do set/a$par+=1^&set $par0=^^^!$par0^^^!,%%?^&set $par^^^!$par^^^!=%%?%$n1c%
%=          =%if defined $par0 set $par0=^^^!$par0:~1^^^!%$n1c%
!==^^^!^
%=          =%!necho_!  $par: '^^^!$par^^^!'%$n1c%
%=          =%!necho_!  $par0: '^^^!$par0^^^!'%$n1c%
%=          =%set $r=^^^!$r^^^!,$par,$par0%$n1c%
!==^^^!^
%=          =%set $p=^&set ?=^&!forÇ_! (1,1,^^^!$par^^^!) do (^
!==^^^!^
%=               =%!necho_!  $par%%ç: '^^^!$par%%ç^^^!'%$n1c%
%=               =%set $r=^^^!$r^^^!,$par%%ç%$n1c%
%=               =%if defined ? (^
!==^^^!^
%=                    =%set $p=^^^!$p^^^!,^^^!$par%%ç^^^!%$n1c%
%=                    =%!deQuoteLH_!$par%%ç%$n1c%
%=                    =%!necho_!  $^^^!?^^^!: '^^^!$par%%ç^^^!'%$n1c%
%=                    =%set $^^^!?^^^!=^^^!$par%%ç^^^!%$n1c%
%=                    =%set $r=^^^!$r^^^!,$^^^!?^^^!%$n1c%
%=                    =%set ?=^
!==^^^!^
%=               =%)else if ^^^!$par%%ç:~0%e7%,1^^^!==/ (^
!==^^^!^
%=                    =%if ^^^!$par%%ç:~-1^^^!==: (^
!==^^^!^
%=                         =%set ?=^^^!$par%%ç:~1,-1^^^!%$n1c%
%=                         =%!necho_!  $^^^!?^^^!: '1'^
!==^^^!^
%=                    =%)else (^
!==^^^!^
%=                         =%!necho_!  $^^^!$par%%ç:~1^^^!: '1'%$n1c%
%=                         =%set $^^^!$par%%ç:~1^^^!=1%$n1c%
%=                         =%set $r=^^^!$r^^^!,$^^^!$par%%ç:~1^^^!%$n1c%
%=                         =%set $p=^^^!$p^^^!,1^
%=                    =%)^
!==^^^!^
%=               =%)else set $p=^^^!$p^^^!,^^^!$par%%ç^^^!^
!==^^^!^
%=          =%)%$n1c%
%=          =%if defined $p set $p=^^^!$p:~1^^^!%$n1c%
%=          =%!necho_!  $p: '^^^!$p^^^!'%$n1c%
%=          =%set $r=^^^!$r^^^!,$p%$n1c%
!==^^^!^
%=     =%!forQ_! (^^^!$err^^^!) do (^
%=          =%!nErrL!^&!endlocalL_!^^^!$r^^^!%$n1c%
%=          =%cmd/cexit %%?^
%=     =%))else setlocal enableDelayedExpansion^&set _="
:: )
2>%_Dcon% %macroEnd%
%endlocalR_% (
%$%
)
::
%@bTryAssert%
:: (
     setlocal enableDelayedExpansion
     :: (
          ( %toParams_% /arg0: "this work^^ s^!" /arg1: this_^^^^works^^^! /arg2 not_recognized ) ||( %assertFail_% )
          ( %toParams_% )                                                                         ||( %assertFail_% )
     :: )
     endlocal
:: )
::--------------------------------------------------------------------------------------------------------------------------
::
goto :skip "()"
%endoftest%
:skip ()
The resulting standalone bytefile;

Code: Select all

@echo off &title %~n0 &prompt $G &<nul set /p "= " &chcp 850 &goto :§main_ () %=     prompt minimalistic, codepage 850     =%
::--------------------------------------------------------------------------------------------------------------------------
:: toIndependentByteCode ( byteCode[independent] )
::--------------------------------------------------------------------------------------------------------------------------
:: (
::   sourceFile           : none; this is a unitTest
::    sourceFunction      : §label0
::    programmer          : tooComplex
::
::   sourceProject        : doskitXP32x86 v20131205
::    supported platform/s: windows XP - 32bit versions - x86 architectures
::    supported languages : dutch, english ( experimental ), international ( experimental )
::    programmer          : tooComplex
::
::   dump type            : independent
::    /independent        : external executables are still required to run the application
::    /linked             : external executables and project files are still required to run the application
::
::   special thanks to    : admin, jeb, dBenham, aGerman from www.dosTips.COM, the dosTips team and members
:: )
::--------------------------------------------------------------------------------------------------------------------------

::--------------------------------------------------------------------------------------------------------------------------
:§init_ ( support $cr, $lf, $esc, $sub, $tab, $bs ) [requires disableDelayedExpansion]
::--------------------------------------------------------------------------------------------------------------------------
:: (
     title toIndependentByteCode

     :: $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 Asci-0x0A
     set $lf=^


     :: $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=%%?"

     :: $n1c newLine+continuation, 1 expansions, 0sets, 1echo
     set ^"$n1c=^^^%$lf%%$lf%^%$lf%%$lf%^^"

     :: common variables
     set /a $bUninstallOnExit = 0
     set /a $err              = 0
:: )
exit /b %$err%
::--------------------------------------------------------------------------------------------------------------------------

::--------------------------------------------------------------------------------------------------------------------------
:§memRestore_ (toParams_) [requires enableDelayedExpansion]
::--------------------------------------------------------------------------------------------------------------------------
:: (
     echo(&<nul set/p= restoring memory...

     :: (toParams_) '4146' bytes on file, '2530' bytes in memory.
     :: (
%=     =%set ^"toParams_=for %%? in (1,2) do if %%?==2 (for %%? in (1,2) do if %%?==2 (for %%? in (^^^!~^^^!) do (if ^^^!§inline^^^!.==. echo(%$n1c%
%=          =%set/a$debug+=1,$err=0,§inline=1%$n1c%
%=          =%set $trace=%%~?%$n1c%
%=          =%set $debug[^^^!$debug^^^!]=%%~?%$n1c%
%=          =%set $%%~?.p=^^^!*^^^!^&if ^^^!*:~0^^^^,1^^^!==^^^^^^^^^^^^^^^! set $%%~?.p=^^^!*:~1^^^!%$n1c%
%=          =%set $r=$err))else set ~=toParams_%$n1c%
%=          =%echo(^&^<nul set/p= toParams_^^^^(^^^!_^^^!^^^^)%$n1c%
%=          =%for /l %%ç in (1,1,^^^!$par^^^!) do set $par%%ç=%$n1c%
%=          =%for %%? in (1,2) do if %%?==2 (for %%? in (^^^!*^^^!) do set ?=^&set ?=^^^!%%~?^^^!^&^&(set ?=^^^!?:^"=^"^"^^^!%$n1c%
%=          =%call set ^"?=%%^^^^?:^^^^^^^!=#^"#^"^^^^^^^!%%^"%$n1c%
%=          =%set ^"?=^^^!?:^^^^=^^^^^^^^^^^!^"^&set ^"?=^^^!?:#^"#^"=^^^^^^^!^"%$n1c%
%=          =%set ?=^^^!?:^"^"=^"^^^!%$n1c%
%=          =%set %%~?=^^^!?^^^!))else set *=_%$n1c%
%=          =%set $par=^&set $par0=^&for %%? in ( ^^^!_^^^!) do set/a$par+=1^&set $par0=^^^!$par0^^^!,%%?^&set $par^^^!$par^^^!=%%?%$n1c%
%=          =%if defined $par0 set $par0=^^^!$par0:~1^^^!%$n1c%
%=          =%echo(^&^<nul set/p=  $par: '^^^!$par^^^!'%$n1c%
%=          =%echo(^&^<nul set/p=  $par0: '^^^!$par0^^^!'%$n1c%
%=          =%set $r=^^^!$r^^^!,$par,$par0%$n1c%
%=          =%set $p=^&set ?=^&for /l %%ç in (1,1,^^^!$par^^^!) do (echo(^&^<nul set/p=  $par%%ç: '^^^!$par%%ç^^^!'%$n1c%
%=          =%set $r=^^^!$r^^^!,$par%%ç%$n1c%
%=          =%if defined ? (set $p=^^^!$p^^^!,^^^!$par%%ç^^^!%$n1c%
%=          =%for %%? in (1,2) do if %%?==2 for /f ^"tokens=1-26delims=,%$tab% ^" %%a in (^"^^^!*^^^!^") do (set _=^&set _=^^^!%%~a^^^!^&^&if ^^^!_:~0^^^^,1^^^!==^^^^^" if ^^^!_:~-1^^^!==^^^^^" set %%~a=^^^!_:~1,-1^^^!)else set *=$par%%ç%$n1c%
%=          =%echo(^&^<nul set/p=  $^^^!?^^^!: '^^^!$par%%ç^^^!'%$n1c%
%=          =%set $^^^!?^^^!=^^^!$par%%ç^^^!%$n1c%
%=          =%set $r=^^^!$r^^^!,$^^^!?^^^!%$n1c%
%=          =%set ?=)else if ^^^!$par%%ç:~0^^^^,1^^^!==/ (if ^^^!$par%%ç:~-1^^^!==: (set ?=^^^!$par%%ç:~1,-1^^^!%$n1c%
%=          =%echo(^&^<nul set/p=  $^^^!?^^^!: '1')else (echo(^&^<nul set/p=  $^^^!$par%%ç:~1^^^!: '1'%$n1c%
%=          =%set $^^^!$par%%ç:~1^^^!=1%$n1c%
%=          =%set $r=^^^!$r^^^!,$^^^!$par%%ç:~1^^^!%$n1c%
%=          =%set $p=^^^!$p^^^!,1))else set $p=^^^!$p^^^!,^^^!$par%%ç^^^!)%$n1c%
%=          =%if defined $p set $p=^^^!$p:~1^^^!%$n1c%
%=          =%echo(^&^<nul set/p=  $p: '^^^!$p^^^!'%$n1c%
%=          =%set $r=^^^!$r^^^!,$p%$n1c%
%=          =%for %%? in (^^^!$err^^^!) do (echo(^&(if ^^^!$err:~0^^^^,1^^^!==- (set ?=^^^!$err:~1^^^!)else set ?=^^^!$err^^^!%$n1c%
%=          =%for %%? in (^"$^^^!?^^^!.error^") do if ^^^!?^^^! neq 0 (^<nul set/p= [error:^^^!$err^^^!] ^^^!%%~?^^^! ^^^^^^^^^^^^^^^!)else ^<nul set/p= [^^^!%%~?^^^!:^^^!$err^^^!])^&for %%? in (1,2) do if %%?==2 (set ¤=^&for %%? in (^^^!º^^^!) do if ^^^!¤^^^!.==. set/a¤=0%%~? 2^>nul^&^&call set º=%%º:*^^^!¤^^^!=%%^|^|set/a¤=1%$n1c%
%=          =%set _=^&for %%? in (^^^!º^^^!) do (set ?=^^^!%%~?^^^!^&if defined ? (set ?=^^^!?:§=§0^^^!%$n1c%
%=          =%set ?=^^^!?:^^^^!$lf!!$lf!=§0l^^^!%$n1c%
%=          =%for /f %%1 in (^"^^^!$cr^^^! ^") do set ?=^^^!?:%%1=§0c^^^!)%$n1c%
%=          =%set _=^^^!_^^^!§l%%~?=^^^!?^^^!)%$n1c%
%=          =%set _=^^^!_:^"=^"^"^^^!%$n1c%
%=          =%set ^"_=^^^!_:^^^^=§9^^^!^"^&call set ^"_=%%^^^^_:^^^^^^^!=§3%%^"%$n1c%
%=          =%for /f ^"delims=^" %%r in (^"^^^!_:~2^^^!^") do (for /l %%^^^! in (1,1,^^^!¤^^^!) do endlocal%$n1c%
%=          =%set ?=^^^!^&setlocal enableDelayedExpansion%$n1c%
%=          =%set _=%%r%$n1c%
%=          =%call set ^"_=%%^^^^_:§3=§3^^^^^^^!%%^"^&if ^^^!?^^^!.==. (set ^"_=^^^!_:§9=^^^^^^^^^^^!^"^&set ^"_=^^^!_:§3=^^^^^^^!^"%$n1c%
%=          =%)else set ^"_=^^^!_:§9=^^^^^^^!^"^&set _=^^^!_:§3=^^^!%$n1c%
%=          =%set _=^^^!_:^"^"=^"^^^!%$n1c%
%=          =%for %%? in (^"^^^!$lf^^^!^") do set _=^^^!_:§l=%%~?^^^!%$n1c%
%=          =%set _=^^^!_:§0=§^^^!%$n1c%
%=          =%for /f delims^^^^=^^^^ eol^^^^= %%r in (^"^^^!_^^^!^") do (endlocal%$n1c%
%=          =%if ^^^!.==. (set _=%%r^^^!%$n1c%
%=          =%set _=^^^!_:§l=^^^^!$lf!!$lf!^^^!%$n1c%
%=          =%for /f %%1 in (^"^^^!$cr^^^! ^") do set _=^^^!_:§c=%%1^^^!%$n1c%
%=          =%set ^"^^^!_^^^!^"^^^!)else set ^"%%r^"%$n1c%
%=          =%setlocal enableDelayedExpansion)%$n1c%
%=          =%endlocal))else set º=^^^!$r^^^!%$n1c%
%=          =%cmd/cexit %%?))else setlocal enableDelayedExpansion^&set _=" !
     :: )

     <nul set/p=%$bs%%$bs% [done]
:: )
exit /b %$err%
::--------------------------------------------------------------------------------------------------------------------------

::--------------------------------------------------------------------------------------------------------------------------
:§main_ ( %* )
::--------------------------------------------------------------------------------------------------------------------------
setlocal enableExtensions disableDelayedExpansion
:: (
     :: set common variables &functions
     :: (
          call :§init_ ()
     :: )

     :: get commandLineArgs( %* )
     :: (
          (call set $par0=%%^*) %= beware that set arg * can break code between braces unless called    =%
     :: )                       %= $lf prevents winXP exception; 'input corrupt or incorrectly escaped' =%

     :: load memory dump, call function dump
     setlocal enableDelayedExpansion &call :§memRestore_ ()
     :: (
          call :§label0 !$par0! ^!
     :: )
     endlocal &set /a $err = %$err%
:: )
endlocal &exit %$err%
::--------------------------------------------------------------------------------------------------------------------------

::--------------------------------------------------------------------------------------------------------------------------
:§label0 ( %* )
::--------------------------------------------------------------------------------------------------------------------------
:: (
     :: see_(toParams_)
     setlocal enableDelayedExpansion
     :: (
          ( echo( ) &for %%? in ( toParams_ ) do echo(&<nul set/p= %%~?=!%%~?!
     :: )
     endlocal

     :: unitTest_(toParams_)
     :: (
          ( echo( ) &( %toParams_% /arg0: "this work^^ s^!" )
     :: )
     echo(&<nul set/p= &pause
:: )
exit /b %$err%
::--------------------------------------------------------------------------------------------------------------------------
The byteFile can only be executed, I can no longer make any major changes to it unless I make them in the sourceFiles because the code is too obfuscated, almost impossible to reverse engineer and cannot explain itself, it is now a standalone program. The output;

Code: Select all

 Actieve codetabel: 850

 restoring memory. [done]

 toParams_=for %? in (1,2) do if %?==2 (for %? in (1,2) do if %?==2 (for %? in (
!~!) do (if !ºinline!.==. echo(
set/a$debug+=1,$err=0,ºinline=1
set $trace=%~?
set $debug[!$debug!]=%~?
set $%~?.p=!*!&if !*:~0^,1!==^^^! set $%~?.p=!*:~1!
set $r=$err))else set ~=toParams_
echo(&<nul set/p= toParams_^(!_!^)
for /l %þ in (1,1,!$par!) do set $par%þ=
for %? in (1,2) do if %?==2 (for %? in (!*!) do set ?=&set ?=!%~?!&&(set ?=!?:"=
""!
call set "?=%^?:^!=#"#"^!%"
set "?=!?:^=^^!"&set "?=!?:#"#"=^!"
set ?=!?:""="!
set %~?=!?!))else set *=_
set $par=&set $par0=&for %? in ( !_!) do set/a$par+=1&set $par0=!$par0!,%?&set $
par!$par!=%?
if defined $par0 set $par0=!$par0:~1!
echo(&<nul set/p=  $par: '!$par!'
echo(&<nul set/p=  $par0: '!$par0!'
set $r=!$r!,$par,$par0
set $p=&set ?=&for /l %þ in (1,1,!$par!) do (echo(&<nul set/p=  $par%þ: '!$par%þ
!'
set $r=!$r!,$par%þ
if defined ? (set $p=!$p!,!$par%þ!
for %? in (1,2) do if %?==2 for /f "tokens=1-26delims=,  " %a in ("!*!") do (set
 _=&set _=!%~a!&&if !_:~0^,1!==^" if !_:~-1!==^" set %~a=!_:~1,-1!)else set *=$p
ar%þ
echo(&<nul set/p=  $!?!: '!$par%þ!'
set $!?!=!$par%þ!
set $r=!$r!,$!?!
set ?=)else if !$par%þ:~0^,1!==/ (if !$par%þ:~-1!==: (set ?=!$par%þ:~1,-1!
echo(&<nul set/p=  $!?!: '1')else (echo(&<nul set/p=  $!$par%þ:~1!: '1'
set $!$par%þ:~1!=1
set $r=!$r!,$!$par%þ:~1!
set $p=!$p!,1))else set $p=!$p!,!$par%þ!)
if defined $p set $p=!$p:~1!
echo(&<nul set/p=  $p: '!$p!'
set $r=!$r!,$p
for %? in (!$err!) do (echo(&(if !$err:~0^,1!==- (set ?=!$err:~1!)else set ?=!$e
rr!
for %? in ("$!?!.error") do if !?! neq 0 (<nul set/p= [error:!$err!] !%~?! ^^^!)
else <nul set/p= [!%~?!:!$err!])&for %? in (1,2) do if %?==2 (set ñ=&for %? in (
!║!) do if !ñ!.==. set/añ=0%~? 2>nul&&call set ║=%║:*!ñ!=%||set/añ=1
set _=&for %? in (!║!) do (set ?=!%~?!&if defined ? (set ?=!?:º=º0!
set ?=!?:^

=º0l!
for /f %1 in ("!$cr! ") do set ?=!?:%1=º0c!)
set _=!_!ºl%~?=!?!)
set _=!_:"=""!
set "_=!_:^=º9!"&call set "_=%^_:^!=º3%"
for /f "delims=" %r in ("!_:~2!") do (for /l %! in (1,1,!ñ!) do endlocal
set ?=!&setlocal enableDelayedExpansion
set _=%r
call set "_=%^_:º3=º3^!%"&if !?!.==. (set "_=!_:º9=^^!"&set "_=!_:º3=^!"
)else set "_=!_:º9=^!"&set _=!_:º3=!
set _=!_:""="!
for %? in ("!$lf!") do set _=!_:ºl=%~?!
set _=!_:º0=º!
for /f delims^=^ eol^= %r in ("!_!") do (endlocal
if !.==. (set _=%r!
set _=!_:ºl=^

!
for /f %1 in ("!$cr! ") do set _=!_:ºc=%1!
set "!_!"!)else set "%r"
setlocal enableDelayedExpansion)
endlocal))else set ║=!$r!
cmd/cexit %?))else setlocal enableDelayedExpansion&set _=


 toParams_( /arg0: "this work^ s!" )
  $par: '2'
  $par0: '/arg0:,"this work^ s!"'
  $par1: '/arg0:'
  $arg0: '1'
  $par2: '"this work^ s!"'
  $arg0: 'this work^ s!'
  $p: '"this work^ s!"'
 [ok:0]
 Druk op een toets om door te gaan. . .
I had the intention to solve batch related problems quickly using my library's abstract functions. I succeeded in sucking all requirements out the library and pumping them into a single file automatically. The benefits are obvious to me, but the means seem to have passed the goal. The code is obfuscated. I'm not even sure whether I helped anyone at all. Foxi said he does not like this obfuscated code solutions to be posted at all, at least he'll never run it.

What I hate more than programming is reinventing the wheel. In an ideal world, code is nothing more than a technical artifact from a model.

Blyanadams
Posts: 23
Joined: 20 Dec 2013 05:41

Re: byteCode, a java concept ?

#2 Post by Blyanadams » 24 Dec 2013 00:28

first of all kudos to you and others coming up with all these ingenuity.

But i would post this question to you. What is it you are trying to achieve by doing all these (besides optimization , whatever that means.)

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

Re: byteCode, a java concept ?

#3 Post by Ed Dyreen » 24 Dec 2013 00:35

I like posting batch solutions and I admit that I am often too lazy to code from scratch.
I have the feeling posting these codes is rarely going to be okay. :?

Blyanadams
Posts: 23
Joined: 20 Dec 2013 05:41

Re: byteCode, a java concept ?

#4 Post by Blyanadams » 24 Dec 2013 00:40

Ed Dyreen wrote:I like posting batch solutions.

that's great, but i don't think anyone is going to use it. Just my frank opinion.

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

Re: byteCode, a java concept ?

#5 Post by Ed Dyreen » 24 Dec 2013 00:57

Blyanadams wrote:
Ed Dyreen wrote:I like posting batch solutions.

that's great, but i don't think anyone is going to use it. Just my frank opinion.
Anyone is going to use what ?

Blyanadams
Posts: 23
Joined: 20 Dec 2013 05:41

Re: byteCode, a java concept ?

#6 Post by Blyanadams » 24 Dec 2013 01:01

Ed Dyreen wrote:Anyone is going to use what ?

well, you should us your "library" which is rather obfuscated right? So i am referring to that. Don't think anyone is going to use it , in a productive sense.

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

Re: byteCode, a java concept ?

#7 Post by Ed Dyreen » 24 Dec 2013 01:07

what has my "library" to do with it and why should anyone use my "library" in a productive sense ?

Blyanadams
Posts: 23
Joined: 20 Dec 2013 05:41

Re: byteCode, a java concept ?

#8 Post by Blyanadams » 24 Dec 2013 01:20

Ed Dyreen wrote:what has my "library" to do with it and why should anyone use my "library" in a productive sense ?

so what's your purpose then, by posting it? You want someone to use it or not? Or just posting for fun? No offense, but i really think you did a marvelous job trying to create your own "libraries" working in batch. Like i said, its my frank opinion.

ShadowThief
Expert
Posts: 1167
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: byteCode, a java concept ?

#9 Post by ShadowThief » 24 Dec 2013 01:49

Blyanadams wrote:
Ed Dyreen wrote:what has my "library" to do with it and why should anyone use my "library" in a productive sense ?

so what's your purpose then, by posting it? You want someone to use it or not? Or just posting for fun? No offense, but i really think you did a marvelous job trying to create your own "libraries" working in batch. Like i said, its my frank opinion.

Proof of concept.

einstein1969
Expert
Posts: 969
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: byteCode, a java concept ?

#10 Post by einstein1969 » 24 Dec 2013 06:35

Ed Dyreen wrote:Once I posted a library, a collection of batch functions and macros and some tools for convenient batch scripting. This allows me to write less error prone scripts much faster due to the high abstraction a library provides.

Unfortunately the more macro's included in a library the longer it takes to initialize. One way to reduce load and optimize performance is to only include those macro's that will be used. What if this process could be automated ? What if I could write a batch file using functions stored in other files and then having it processed in some way so it can run independently from its library ? Having a byteFile pumped out automatically which would have higher performance and smaller file-size than the original.

The script I am writing may use this particular library function;

Code: Select all

::--------------------------------------------------------------------------------------------------------------------------
set "$defines=toParams_"
::--------------------------------------------------------------------------------------------------------------------------
:: last updated       : 2012^11^14
:: support            : onDelayed, delayedChars, related chaining
::
:: -$par0: is a reconstructed paramRAW.
:: -$par: is the number of individual arguments.
:: -Arguments are only valid if they start with a slash and  are combined if they end with a colon.
::  All other cases are ignored and added raw to $p.
:: -If the argument is valid If the argument is combined (
::    the part before the colon is the variable name and the part behind the colon is the value.
::  ) else the argument is considered boolean with value true ( Microsoft programs parse command-line arguments similarly ).
:: -$p: is the raw data string.
:: -The default delimiters apply unless they are enclosed in double quotes.
:: -Double quotes that are part of the argument and unevenly distributed need to be escaped.
::
set ^"$usage.%$defines%=^
%=     =% use: ( %%toParams_%% #etc.. )%$n1c%
%=     =% ret: string $p, array $par, all variables as boolean or string%$n1c%
%=     =% err: unaffected, panic otherwise"
::
2>%_Dcon% ( %macroStart_% enableDelayedExpansion )
:: (
%=     =%set ^"!$defines!=!forQ_! (1,2) do if %%?==2 (!setLocal_!!$defines!%$n1c%
%=          =%!necho_! !$defines!%e7%(^^^!_^^^!%e7%)%$n1c%
!==^^^!^
%=          =%!forÇ_! (1,1,^^^!$par^^^!) do set $par%%ç=%$n1c%
%=          =%!reDelayLH_!_%$n1c%
%=          =%set $par=^&set $par0=^&!forQ_! (^
%=               =% ^^^!_^^^!^
%=          =%) do set/a$par+=1^&set $par0=^^^!$par0^^^!,%%?^&set $par^^^!$par^^^!=%%?%$n1c%
%=          =%if defined $par0 set $par0=^^^!$par0:~1^^^!%$n1c%
!==^^^!^
%=          =%!necho_!  $par: '^^^!$par^^^!'%$n1c%
%=          =%!necho_!  $par0: '^^^!$par0^^^!'%$n1c%
%=          =%set $r=^^^!$r^^^!,$par,$par0%$n1c%
!==^^^!^
%=          =%set $p=^&set ?=^&!forÇ_! (1,1,^^^!$par^^^!) do (^
!==^^^!^
%=               =%!necho_!  $par%%ç: '^^^!$par%%ç^^^!'%$n1c%
%=               =%set $r=^^^!$r^^^!,$par%%ç%$n1c%
%=               =%if defined ? (^
!==^^^!^
%=                    =%set $p=^^^!$p^^^!,^^^!$par%%ç^^^!%$n1c%
%=                    =%!deQuoteLH_!$par%%ç%$n1c%
%=                    =%!necho_!  $^^^!?^^^!: '^^^!$par%%ç^^^!'%$n1c%
%=                    =%set $^^^!?^^^!=^^^!$par%%ç^^^!%$n1c%
%=                    =%set $r=^^^!$r^^^!,$^^^!?^^^!%$n1c%
%=                    =%set ?=^
!==^^^!^
%=               =%)else if ^^^!$par%%ç:~0%e7%,1^^^!==/ (^
!==^^^!^
%=                    =%if ^^^!$par%%ç:~-1^^^!==: (^
!==^^^!^
%=                         =%set ?=^^^!$par%%ç:~1,-1^^^!%$n1c%
%=                         =%!necho_!  $^^^!?^^^!: '1'^
!==^^^!^
%=                    =%)else (^
!==^^^!^
%=                         =%!necho_!  $^^^!$par%%ç:~1^^^!: '1'%$n1c%
%=                         =%set $^^^!$par%%ç:~1^^^!=1%$n1c%
%=                         =%set $r=^^^!$r^^^!,$^^^!$par%%ç:~1^^^!%$n1c%
%=                         =%set $p=^^^!$p^^^!,1^
%=                    =%)^
!==^^^!^
%=               =%)else set $p=^^^!$p^^^!,^^^!$par%%ç^^^!^
!==^^^!^
%=          =%)%$n1c%
%=          =%if defined $p set $p=^^^!$p:~1^^^!%$n1c%
%=          =%!necho_!  $p: '^^^!$p^^^!'%$n1c%
%=          =%set $r=^^^!$r^^^!,$p%$n1c%
!==^^^!^
%=     =%!forQ_! (^^^!$err^^^!) do (^
%=          =%!nErrL!^&!endlocalL_!^^^!$r^^^!%$n1c%
%=          =%cmd/cexit %%?^
%=     =%))else setlocal enableDelayedExpansion^&set _="
:: )
2>%_Dcon% %macroEnd%
%endlocalR_% (
%$%
)
::
%@bTryAssert%
:: (
     setlocal enableDelayedExpansion
     :: (
          ( %toParams_% /arg0: "this work^^ s^!" /arg1: this_^^^^works^^^! /arg2 not_recognized ) ||( %assertFail_% )
          ( %toParams_% )                                                                         ||( %assertFail_% )
     :: )
     endlocal
:: )
::--------------------------------------------------------------------------------------------------------------------------
::
goto :skip "()"
%endoftest%
:skip ()
The resulting standalone bytefile;

Code: Select all

@echo off &title %~n0 &prompt $G &<nul set /p "= " &chcp 850 &goto :§main_ () %=     prompt minimalistic, codepage 850     =%
::--------------------------------------------------------------------------------------------------------------------------
:: toIndependentByteCode ( byteCode[independent] )
::--------------------------------------------------------------------------------------------------------------------------
:: (
::   sourceFile           : none; this is a unitTest
::    sourceFunction      : §label0
::    programmer          : tooComplex
::
::   sourceProject        : doskitXP32x86 v20131205
::    supported platform/s: windows XP - 32bit versions - x86 architectures
::    supported languages : dutch, english ( experimental ), international ( experimental )
::    programmer          : tooComplex
::
::   dump type            : independent
::    /independent        : external executables are still required to run the application
::    /linked             : external executables and project files are still required to run the application
::
::   special thanks to    : admin, jeb, dBenham, aGerman from www.dosTips.COM, the dosTips team and members
:: )
::--------------------------------------------------------------------------------------------------------------------------

::--------------------------------------------------------------------------------------------------------------------------
:§init_ ( support $cr, $lf, $esc, $sub, $tab, $bs ) [requires disableDelayedExpansion]
::--------------------------------------------------------------------------------------------------------------------------
:: (
     title toIndependentByteCode
     set $lf=^


     ::
     set ^"$n1c=^^^%$lf%%$lf%^%$lf%%$lf%^^"
     ::
     for /f "delims=#" %%? in (

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

     ) do set "$esc=%%?"
     ::
     >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"
     ::
     for /f "skip=4tokens=2delims=pR " %%? in (

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

     ) do set "$tab=%%?"
     ::
     for /f "delims=#" %%? in (

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

     ) do set "$bs=%%?"
     ::
     set "$bs=%$bs:~0,1%"
     ::
     set /a $bUninstallOnExit = 0
     set /a $err              = 0
:: )
exit /b %$err%
::--------------------------------------------------------------------------------------------------------------------------

::--------------------------------------------------------------------------------------------------------------------------
:§memRestore_ (toParams_) [requires enableDelayedExpansion]
::--------------------------------------------------------------------------------------------------------------------------
:: (
     echo(&<nul set/p= restoring memory...

     :: (toParams_) '4146' bytes on file, '2530' bytes in memory.
     :: (
%=     =%set ^"toParams_=for %%? in (1,2) do if %%?==2 (for %%? in (1,2) do if %%?==2 (for %%? in (^^^!~^^^!) do (if ^^^!§inline^^^!.==. echo(%$n1c%
%=          =%set/a$debug+=1,$err=0,§inline=1%$n1c%
%=          =%set $trace=%%~?%$n1c%
%=          =%set $debug[^^^!$debug^^^!]=%%~?%$n1c%
%=          =%set $%%~?.p=^^^!*^^^!^&if ^^^!*:~0^^^^,1^^^!==^^^^^^^^^^^^^^^! set $%%~?.p=^^^!*:~1^^^!%$n1c%
%=          =%set $r=$err))else set ~=toParams_%$n1c%
%=          =%echo(^&^<nul set/p= toParams_^^^^(^^^!_^^^!^^^^)%$n1c%
%=          =%for /l %%ç in (1,1,^^^!$par^^^!) do set $par%%ç=%$n1c%
%=          =%for %%? in (1,2) do if %%?==2 (for %%? in (^^^!*^^^!) do set ?=^&set ?=^^^!%%~?^^^!^&^&(set ?=^^^!?:^"=^"^"^^^!%$n1c%
%=          =%call set ^"?=%%^^^^?:^^^^^^^!=#^"#^"^^^^^^^!%%^"%$n1c%
%=          =%set ^"?=^^^!?:^^^^=^^^^^^^^^^^!^"^&set ^"?=^^^!?:#^"#^"=^^^^^^^!^"%$n1c%
%=          =%set ?=^^^!?:^"^"=^"^^^!%$n1c%
%=          =%set %%~?=^^^!?^^^!))else set *=_%$n1c%
%=          =%set $par=^&set $par0=^&for %%? in ( ^^^!_^^^!) do set/a$par+=1^&set $par0=^^^!$par0^^^!,%%?^&set $par^^^!$par^^^!=%%?%$n1c%
%=          =%if defined $par0 set $par0=^^^!$par0:~1^^^!%$n1c%
%=          =%echo(^&^<nul set/p=  $par: '^^^!$par^^^!'%$n1c%
%=          =%echo(^&^<nul set/p=  $par0: '^^^!$par0^^^!'%$n1c%
%=          =%set $r=^^^!$r^^^!,$par,$par0%$n1c%
%=          =%set $p=^&set ?=^&for /l %%ç in (1,1,^^^!$par^^^!) do (echo(^&^<nul set/p=  $par%%ç: '^^^!$par%%ç^^^!'%$n1c%
%=          =%set $r=^^^!$r^^^!,$par%%ç%$n1c%
%=          =%if defined ? (set $p=^^^!$p^^^!,^^^!$par%%ç^^^!%$n1c%
%=          =%for %%? in (1,2) do if %%?==2 for /f ^"tokens=1-26delims=,%$tab% ^" %%a in (^"^^^!*^^^!^") do (set _=^&set _=^^^!%%~a^^^!^&^&if ^^^!_:~0^^^^,1^^^!==^^^^^" if ^^^!_:~-1^^^!==^^^^^" set %%~a=^^^!_:~1,-1^^^!)else set *=$par%%ç%$n1c%
%=          =%echo(^&^<nul set/p=  $^^^!?^^^!: '^^^!$par%%ç^^^!'%$n1c%
%=          =%set $^^^!?^^^!=^^^!$par%%ç^^^!%$n1c%
%=          =%set $r=^^^!$r^^^!,$^^^!?^^^!%$n1c%
%=          =%set ?=)else if ^^^!$par%%ç:~0^^^^,1^^^!==/ (if ^^^!$par%%ç:~-1^^^!==: (set ?=^^^!$par%%ç:~1,-1^^^!%$n1c%
%=          =%echo(^&^<nul set/p=  $^^^!?^^^!: '1')else (echo(^&^<nul set/p=  $^^^!$par%%ç:~1^^^!: '1'%$n1c%
%=          =%set $^^^!$par%%ç:~1^^^!=1%$n1c%
%=          =%set $r=^^^!$r^^^!,$^^^!$par%%ç:~1^^^!%$n1c%
%=          =%set $p=^^^!$p^^^!,1))else set $p=^^^!$p^^^!,^^^!$par%%ç^^^!)%$n1c%
%=          =%if defined $p set $p=^^^!$p:~1^^^!%$n1c%
%=          =%echo(^&^<nul set/p=  $p: '^^^!$p^^^!'%$n1c%
%=          =%set $r=^^^!$r^^^!,$p%$n1c%
%=          =%for %%? in (^^^!$err^^^!) do (echo(^&(if ^^^!$err:~0^^^^,1^^^!==- (set ?=^^^!$err:~1^^^!)else set ?=^^^!$err^^^!%$n1c%
%=          =%for %%? in (^"$^^^!?^^^!.error^") do if ^^^!?^^^! neq 0 (^<nul set/p= [error:^^^!$err^^^!] ^^^!%%~?^^^! ^^^^^^^^^^^^^^^!)else ^<nul set/p= [^^^!%%~?^^^!:^^^!$err^^^!])^&for %%? in (1,2) do if %%?==2 (set ¤=^&for %%? in (^^^!º^^^!) do if ^^^!¤^^^!.==. set/a¤=0%%~? 2^>nul^&^&call set º=%%º:*^^^!¤^^^!=%%^|^|set/a¤=1%$n1c%
%=          =%set _=^&for %%? in (^^^!º^^^!) do (set ?=^^^!%%~?^^^!^&if defined ? (set ?=^^^!?:§=§0^^^!%$n1c%
%=          =%set ?=^^^!?:^^^^!$lf!!$lf!=§0l^^^!%$n1c%
%=          =%for /f %%1 in (^"^^^!$cr^^^! ^") do set ?=^^^!?:%%1=§0c^^^!)%$n1c%
%=          =%set _=^^^!_^^^!§l%%~?=^^^!?^^^!)%$n1c%
%=          =%set _=^^^!_:^"=^"^"^^^!%$n1c%
%=          =%set ^"_=^^^!_:^^^^=§9^^^!^"^&call set ^"_=%%^^^^_:^^^^^^^!=§3%%^"%$n1c%
%=          =%for /f ^"delims=^" %%r in (^"^^^!_:~2^^^!^") do (for /l %%^^^! in (1,1,^^^!¤^^^!) do endlocal%$n1c%
%=          =%set ?=^^^!^&setlocal enableDelayedExpansion%$n1c%
%=          =%set _=%%r%$n1c%
%=          =%call set ^"_=%%^^^^_:§3=§3^^^^^^^!%%^"^&if ^^^!?^^^!.==. (set ^"_=^^^!_:§9=^^^^^^^^^^^!^"^&set ^"_=^^^!_:§3=^^^^^^^!^"%$n1c%
%=          =%)else set ^"_=^^^!_:§9=^^^^^^^!^"^&set _=^^^!_:§3=^^^!%$n1c%
%=          =%set _=^^^!_:^"^"=^"^^^!%$n1c%
%=          =%for %%? in (^"^^^!$lf^^^!^") do set _=^^^!_:§l=%%~?^^^!%$n1c%
%=          =%set _=^^^!_:§0=§^^^!%$n1c%
%=          =%for /f delims^^^^=^^^^ eol^^^^= %%r in (^"^^^!_^^^!^") do (endlocal%$n1c%
%=          =%if ^^^!.==. (set _=%%r^^^!%$n1c%
%=          =%set _=^^^!_:§l=^^^^!$lf!!$lf!^^^!%$n1c%
%=          =%for /f %%1 in (^"^^^!$cr^^^! ^") do set _=^^^!_:§c=%%1^^^!%$n1c%
%=          =%set ^"^^^!_^^^!^"^^^!)else set ^"%%r^"%$n1c%
%=          =%setlocal enableDelayedExpansion)%$n1c%
%=          =%endlocal))else set º=^^^!$r^^^!%$n1c%
%=          =%cmd/cexit %%?))else setlocal enableDelayedExpansion^&set _=" !
     :: )

     <nul set/p=%$bs%%$bs% [done]
:: )
exit /b %$err%
::--------------------------------------------------------------------------------------------------------------------------

::--------------------------------------------------------------------------------------------------------------------------
:§main_ ( %* )
::--------------------------------------------------------------------------------------------------------------------------
setlocal enableExtensions disableDelayedExpansion
:: (
     :: set common variables &functions
     :: (
          call :§init_ ()
     :: )

     :: get commandLineArgs( %* )
     :: (
          (call set $par0=%%^*) %= beware that set arg * can break code between braces unless called    =%
     :: )                       %= $lf prevents winXP exception; 'input corrupt or incorrectly escaped' =%

     :: load memory dump, call function dump
     setlocal enableDelayedExpansion &call :§memRestore_ ()
     :: (
          call :§label0 !$par0! ^!
     :: )
     endlocal &set /a $err = %$err%
:: )
endlocal &exit %$err%
::--------------------------------------------------------------------------------------------------------------------------

::--------------------------------------------------------------------------------------------------------------------------
:§label0 ( %* )
::--------------------------------------------------------------------------------------------------------------------------
:: (
     :: see_(toParams_)
     setlocal enableDelayedExpansion
     :: (
          ( echo( ) &for %%? in ( toParams_ ) do echo(&<nul set/p= %%~?=!%%~?!
     :: )
     endlocal

     :: unitTest_(toParams_)
     :: (
          ( echo( ) &( %toParams_% /arg0: "this work^^ s^!" )
     :: )
     echo(&<nul set/p= &pause
:: )
exit /b %$err%
::--------------------------------------------------------------------------------------------------------------------------
The byteFile can only be executed, I can no longer make any major changes to it unless I make them in the sourceFiles because the code is too obfuscated, almost impossible to reverse engineer and cannot explain itself, it is now a standalone program. The output;

Code: Select all

 Actieve codetabel: 850

 restoring memory. [done]

 toParams_=for %? in (1,2) do if %?==2 (for %? in (1,2) do if %?==2 (for %? in (
!~!) do (if !ºinline!.==. echo(
set/a$debug+=1,$err=0,ºinline=1
set $trace=%~?
set $debug[!$debug!]=%~?
set $%~?.p=!*!&if !*:~0^,1!==^^^! set $%~?.p=!*:~1!
set $r=$err))else set ~=toParams_
echo(&<nul set/p= toParams_^(!_!^)
for /l %þ in (1,1,!$par!) do set $par%þ=
for %? in (1,2) do if %?==2 (for %? in (!*!) do set ?=&set ?=!%~?!&&(set ?=!?:"=
""!
call set "?=%^?:^!=#"#"^!%"
set "?=!?:^=^^!"&set "?=!?:#"#"=^!"
set ?=!?:""="!
set %~?=!?!))else set *=_
set $par=&set $par0=&for %? in ( !_!) do set/a$par+=1&set $par0=!$par0!,%?&set $
par!$par!=%?
if defined $par0 set $par0=!$par0:~1!
echo(&<nul set/p=  $par: '!$par!'
echo(&<nul set/p=  $par0: '!$par0!'
set $r=!$r!,$par,$par0
set $p=&set ?=&for /l %þ in (1,1,!$par!) do (echo(&<nul set/p=  $par%þ: '!$par%þ
!'
set $r=!$r!,$par%þ
if defined ? (set $p=!$p!,!$par%þ!
for %? in (1,2) do if %?==2 for /f "tokens=1-26delims=,  " %a in ("!*!") do (set
 _=&set _=!%~a!&&if !_:~0^,1!==^" if !_:~-1!==^" set %~a=!_:~1,-1!)else set *=$p
ar%þ
echo(&<nul set/p=  $!?!: '!$par%þ!'
set $!?!=!$par%þ!
set $r=!$r!,$!?!
set ?=)else if !$par%þ:~0^,1!==/ (if !$par%þ:~-1!==: (set ?=!$par%þ:~1,-1!
echo(&<nul set/p=  $!?!: '1')else (echo(&<nul set/p=  $!$par%þ:~1!: '1'
set $!$par%þ:~1!=1
set $r=!$r!,$!$par%þ:~1!
set $p=!$p!,1))else set $p=!$p!,!$par%þ!)
if defined $p set $p=!$p:~1!
echo(&<nul set/p=  $p: '!$p!'
set $r=!$r!,$p
for %? in (!$err!) do (echo(&(if !$err:~0^,1!==- (set ?=!$err:~1!)else set ?=!$e
rr!
for %? in ("$!?!.error") do if !?! neq 0 (<nul set/p= [error:!$err!] !%~?! ^^^!)
else <nul set/p= [!%~?!:!$err!])&for %? in (1,2) do if %?==2 (set ñ=&for %? in (
!║!) do if !ñ!.==. set/añ=0%~? 2>nul&&call set ║=%║:*!ñ!=%||set/añ=1
set _=&for %? in (!║!) do (set ?=!%~?!&if defined ? (set ?=!?:º=º0!
set ?=!?:^

=º0l!
for /f %1 in ("!$cr! ") do set ?=!?:%1=º0c!)
set _=!_!ºl%~?=!?!)
set _=!_:"=""!
set "_=!_:^=º9!"&call set "_=%^_:^!=º3%"
for /f "delims=" %r in ("!_:~2!") do (for /l %! in (1,1,!ñ!) do endlocal
set ?=!&setlocal enableDelayedExpansion
set _=%r
call set "_=%^_:º3=º3^!%"&if !?!.==. (set "_=!_:º9=^^!"&set "_=!_:º3=^!"
)else set "_=!_:º9=^!"&set _=!_:º3=!
set _=!_:""="!
for %? in ("!$lf!") do set _=!_:ºl=%~?!
set _=!_:º0=º!
for /f delims^=^ eol^= %r in ("!_!") do (endlocal
if !.==. (set _=%r!
set _=!_:ºl=^

!
for /f %1 in ("!$cr! ") do set _=!_:ºc=%1!
set "!_!"!)else set "%r"
setlocal enableDelayedExpansion)
endlocal))else set ║=!$r!
cmd/cexit %?))else setlocal enableDelayedExpansion&set _=


 toParams_( /arg0: "this work^ s!" )
  $par: '2'
  $par0: '/arg0:,"this work^ s!"'
  $par1: '/arg0:'
  $arg0: '1'
  $par2: '"this work^ s!"'
  $arg0: 'this work^ s!'
  $p: '"this work^ s!"'
 [ok:0]
 Druk op een toets om door te gaan. . .
I had the intention to solve batch related problems quickly using my library's abstract functions. I succeeded in sucking all requirements out the library and pumping them into a single file automatically. The benefits are obvious to me, but the means seem to have passed the goal. The code is obfuscated. I'm not even sure whether I helped anyone at all. Foxi said he does not like this obfuscated code solutions to be posted at all, at least he'll never run it.

ps; I just noticed there may be a problem with carriage return, seems I escape it once too often, maybe tomorrow...

What I hate more than programming is reinventing the wheel. In an ideal world, code is nothing more than a technical artifact from a model.


Hi Ed,

I start from your rewrite of neorobin Matrix code. I remember the matrix Screensaver.

When i optimize my code for performance i look that the size of environment is important for the execution time of batch code.

I write an example of raytracing in real time that use this trick.

This is useful for many project. For example i develop in the 3D text game with simple raytracing/raymarching/raycast in real time. (I'm trying to use multiprocessing batch to make usable code even more complex.)

I also am trying to create a system that charge on request only what you need.

Automate everything would be wonderful because it would make it easier to write the actual code.

Although I'm not interested in writing code, but to find the limits of the batch dos and overcome them.

I'd like to follow you in this venture and cooperate but for now your code is far too complex for me.

Could you give an example of how to use your code?

thanks for sharing!

Einstein1969

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

Re: byteCode, a java concept ?

#11 Post by Ed Dyreen » 24 Dec 2013 14:55

einstein1969 wrote:Could you give an example of how to use your code?
Copy the "standalone bytefile" code and execute it.

If your system meets the requirements;
supported platform/s: windows XP - 32bit versions - x86 architectures
supported languages : dutch, english ( experimental ), international ( experimental )
The test should succeed and should display the code I posted right below the "standalone bytefile" code. Which proves the concept works.

Suppose someone wants to retrieve value "ThisValue!" from string "IWant/ThisValue!/something/else" in a convenient manner.

Code: Select all

( %StringInString_% $, "IWant" ) &&( ( %eatLeft_% $, "/" ) &( %eatRight_% $, "/", 2 ) ) ||set "$="
is clearer to read, faster to write and more robust than

Code: Select all

for /f "tokens= 2 delims=/" %%? in ( "!$!" ) do if defined...
The convenient manner requires some compiling and this can be automated.

Post Reply