From b9b50a11da669f92202aa660409af562e8ea0719 Mon Sep 17 00:00:00 2001 From: Krumuvecis <66279792+Krumuvecis@users.noreply.github.com> Date: Thu, 7 Apr 2022 19:24:01 +0300 Subject: [PATCH 01/12] structure with placeholders --- demo/placeholder | 0 src/placeholder | 0 tools/placeholder | 0 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 demo/placeholder create mode 100644 src/placeholder create mode 100644 tools/placeholder diff --git a/demo/placeholder b/demo/placeholder new file mode 100644 index 0000000..e69de29 diff --git a/src/placeholder b/src/placeholder new file mode 100644 index 0000000..e69de29 diff --git a/tools/placeholder b/tools/placeholder new file mode 100644 index 0000000..e69de29 From a460d8259b427162560f5d5356c29569eb4db6ef Mon Sep 17 00:00:00 2001 From: Krumuvecis <66279792+Krumuvecis@users.noreply.github.com> Date: Thu, 7 Apr 2022 19:40:14 +0300 Subject: [PATCH 02/12] first files --- src/iniread.bat | 3 +++ src/initest.ini | 1 + src/iniwrite.bat | 3 +++ src/placeholder | 0 src/test.bat | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 53 insertions(+) create mode 100644 src/iniread.bat create mode 100644 src/initest.ini create mode 100644 src/iniwrite.bat delete mode 100644 src/placeholder create mode 100644 src/test.bat diff --git a/src/iniread.bat b/src/iniread.bat new file mode 100644 index 0000000..2814183 --- /dev/null +++ b/src/iniread.bat @@ -0,0 +1,3 @@ +echo Reading not ready yet. +echo. +pause \ No newline at end of file diff --git a/src/initest.ini b/src/initest.ini new file mode 100644 index 0000000..53aeaec --- /dev/null +++ b/src/initest.ini @@ -0,0 +1 @@ +atslega=vertiba \ No newline at end of file diff --git a/src/iniwrite.bat b/src/iniwrite.bat new file mode 100644 index 0000000..cc5a00b --- /dev/null +++ b/src/iniwrite.bat @@ -0,0 +1,3 @@ +echo Writing not ready yet. +echo. +pause \ No newline at end of file diff --git a/src/placeholder b/src/placeholder deleted file mode 100644 index e69de29..0000000 diff --git a/src/test.bat b/src/test.bat new file mode 100644 index 0000000..ddd8dc5 --- /dev/null +++ b/src/test.bat @@ -0,0 +1,46 @@ +@echo off + +REM Initialize variables. +:initialize +set iniFileName=initest.ini + + +REM Script is supposed to start here. +:start +REM cls +echo Are you ready? +echo. +pause + + +REM Read from ini +:read +cls +echo Reading from ini +echo. + +set iniReadFileName=iniread.bat +call %iniReadFileName% + +echo. +echo Done. +echo. +pause + + +REM Write to ini +:write +cls +echo Writing to ini +echo. + +set iniWriteFileName=iniwrite.bat +call %iniWriteFileName% + +echo. +echo Done. +echo. +pause + + +exit \ No newline at end of file From a6776290507482a2648441a7c37bd529493a96d4 Mon Sep 17 00:00:00 2001 From: Krumuvecis <66279792+Krumuvecis@users.noreply.github.com> Date: Thu, 7 Apr 2022 22:12:06 +0300 Subject: [PATCH 03/12] ini read reading inis --- src/iniread.bat | 15 ++++++++++++--- src/initest.ini | 2 +- src/iniwrite.bat | 4 +--- src/test.bat | 29 +++++++++++++++++++---------- 4 files changed, 33 insertions(+), 17 deletions(-) diff --git a/src/iniread.bat b/src/iniread.bat index 2814183..72d34aa 100644 --- a/src/iniread.bat +++ b/src/iniread.bat @@ -1,3 +1,12 @@ -echo Reading not ready yet. -echo. -pause \ No newline at end of file +REM call iniread.bat [file name] [key name] [output value] + +set fileName=%~1 +set keyName=%~2 + +REM delimiter +set delim== + +REM Returns 2nd token separated by delim as 2nd parameter. +for /f "tokens=2 delims=%delim%" %%a in ('find "%keyName%%delim%" %fileName%') do set %~3=%%a + +goto :eof \ No newline at end of file diff --git a/src/initest.ini b/src/initest.ini index 53aeaec..8d06a32 100644 --- a/src/initest.ini +++ b/src/initest.ini @@ -1 +1 @@ -atslega=vertiba \ No newline at end of file +myKey=myValue \ No newline at end of file diff --git a/src/iniwrite.bat b/src/iniwrite.bat index cc5a00b..466716b 100644 --- a/src/iniwrite.bat +++ b/src/iniwrite.bat @@ -1,3 +1 @@ -echo Writing not ready yet. -echo. -pause \ No newline at end of file +echo Writing not ready yet. \ No newline at end of file diff --git a/src/test.bat b/src/test.bat index ddd8dc5..dc756f4 100644 --- a/src/test.bat +++ b/src/test.bat @@ -3,6 +3,7 @@ REM Initialize variables. :initialize set iniFileName=initest.ini +goto start REM Script is supposed to start here. @@ -11,36 +12,44 @@ REM cls echo Are you ready? echo. pause +cls +call :read +cls +call :write +goto end REM Read from ini :read -cls -echo Reading from ini +set keyName=myKey +echo Reading %keyName% from %iniFileName% +call iniread.bat %iniFileName% %keyName% value echo. +echo Value: %value% -set iniReadFileName=iniread.bat -call %iniReadFileName% - -echo. -echo Done. -echo. -pause +call :finishMessage +goto :eof REM Write to ini :write -cls echo Writing to ini echo. set iniWriteFileName=iniwrite.bat call %iniWriteFileName% +call :finishMessage +goto :eof + + +:finishMessage echo. echo Done. echo. pause +goto :eof +:end exit \ No newline at end of file From ba70af086bcf51cbd72328244ca7e426a8e9dc0e Mon Sep 17 00:00:00 2001 From: Krumuvecis <66279792+Krumuvecis@users.noreply.github.com> Date: Thu, 7 Apr 2022 22:20:56 +0300 Subject: [PATCH 04/12] readme update --- ReadMe.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ReadMe.md b/ReadMe.md index a9cd094..f1ff532 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -4,7 +4,9 @@ This is an attempt of *OOP* using `.bat` and `.ini` files. ## Functionality -None. +Ini file reading (`src\iniread.bat iniread.bat [file name] [key name] [output value]`) + +See `src\test.bat` for new functionality. ## Notes From 99e7772e3c447683bc98c9726ccfaaca37130c04 Mon Sep 17 00:00:00 2001 From: Krumuvecis <66279792+Krumuvecis@users.noreply.github.com> Date: Thu, 7 Apr 2022 22:22:05 +0300 Subject: [PATCH 05/12] typo fix --- ReadMe.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReadMe.md b/ReadMe.md index f1ff532..37f2a32 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -4,7 +4,7 @@ This is an attempt of *OOP* using `.bat` and `.ini` files. ## Functionality -Ini file reading (`src\iniread.bat iniread.bat [file name] [key name] [output value]`) +`.ini` file reading (`src\iniread.bat [file name] [key name] [output value]`) See `src\test.bat` for new functionality. From a4651ae8b9ea08a4d49838b9a440072aa9876639 Mon Sep 17 00:00:00 2001 From: Krumuvecis <66279792+Krumuvecis@users.noreply.github.com> Date: Thu, 7 Apr 2022 22:40:37 +0300 Subject: [PATCH 06/12] writing inis --- src/.gitignore | 1 + src/iniwrite.bat | 25 ++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 src/.gitignore diff --git a/src/.gitignore b/src/.gitignore new file mode 100644 index 0000000..9fc955d --- /dev/null +++ b/src/.gitignore @@ -0,0 +1 @@ +iniwrite.ini \ No newline at end of file diff --git a/src/iniwrite.bat b/src/iniwrite.bat index 466716b..f40148a 100644 --- a/src/iniwrite.bat +++ b/src/iniwrite.bat @@ -1 +1,24 @@ -echo Writing not ready yet. \ No newline at end of file +set delim== +set iniWriteFile=iniwrite.ini + +set key1=myKey1 +set key2=myKey2 +set value1=myValue1 +set value2=myValue2 + +call :create +call :addPair %key1% %value1% +call :addPair %key2% %value2% +goto :eof + + +:create +del %iniWriteFile% +echo.> %iniWriteFile% +goto :eof + + +:addPair +set line=%~1%delim%%~2 +echo %line%>> %iniWriteFile% +goto :eof \ No newline at end of file From bc03a65cafc14c051eab6461623171b6d8a3fbb9 Mon Sep 17 00:00:00 2001 From: Krumuvecis <66279792+Krumuvecis@users.noreply.github.com> Date: Fri, 8 Apr 2022 00:24:25 +0300 Subject: [PATCH 07/12] test refactor --- demo/placeholder | 0 {src => demo}/test.bat | 2 ++ 2 files changed, 2 insertions(+) delete mode 100644 demo/placeholder rename {src => demo}/test.bat (94%) diff --git a/demo/placeholder b/demo/placeholder deleted file mode 100644 index e69de29..0000000 diff --git a/src/test.bat b/demo/test.bat similarity index 94% rename from src/test.bat rename to demo/test.bat index dc756f4..810c9c6 100644 --- a/src/test.bat +++ b/demo/test.bat @@ -2,6 +2,7 @@ REM Initialize variables. :initialize +set sourceDir=..\src set iniFileName=initest.ini goto start @@ -12,6 +13,7 @@ REM cls echo Are you ready? echo. pause +cd %sourceDir% cls call :read cls From 7929c7110e1c66408c162a624d2af7801e161167 Mon Sep 17 00:00:00 2001 From: Krumuvecis <66279792+Krumuvecis@users.noreply.github.com> Date: Tue, 12 Apr 2022 19:02:49 +0300 Subject: [PATCH 08/12] improved reading and writing --- demo/test.bat | 57 ----------- src/.gitignore | 1 - src/initest.ini | 1 - src/iniwrite.bat | 24 ----- test/iniReadWriteTest/.gitignore | 1 + test/iniReadWriteTest/ReadMe.md | 1 + test/iniReadWriteTest/footer.bat | 5 + test/iniReadWriteTest/test.bat | 135 +++++++++++++++++++++++++++ tools/iniAdd.bat | 6 ++ tools/iniNew.bat | 6 ++ src/iniread.bat => tools/iniRead.bat | 0 tools/placeholder | 0 12 files changed, 154 insertions(+), 83 deletions(-) delete mode 100644 demo/test.bat delete mode 100644 src/.gitignore delete mode 100644 src/initest.ini delete mode 100644 src/iniwrite.bat create mode 100644 test/iniReadWriteTest/.gitignore create mode 100644 test/iniReadWriteTest/ReadMe.md create mode 100644 test/iniReadWriteTest/footer.bat create mode 100644 test/iniReadWriteTest/test.bat create mode 100644 tools/iniAdd.bat create mode 100644 tools/iniNew.bat rename src/iniread.bat => tools/iniRead.bat (100%) delete mode 100644 tools/placeholder diff --git a/demo/test.bat b/demo/test.bat deleted file mode 100644 index 810c9c6..0000000 --- a/demo/test.bat +++ /dev/null @@ -1,57 +0,0 @@ -@echo off - -REM Initialize variables. -:initialize -set sourceDir=..\src -set iniFileName=initest.ini -goto start - - -REM Script is supposed to start here. -:start -REM cls -echo Are you ready? -echo. -pause -cd %sourceDir% -cls -call :read -cls -call :write -goto end - - -REM Read from ini -:read -set keyName=myKey -echo Reading %keyName% from %iniFileName% -call iniread.bat %iniFileName% %keyName% value -echo. -echo Value: %value% - -call :finishMessage -goto :eof - - -REM Write to ini -:write -echo Writing to ini -echo. - -set iniWriteFileName=iniwrite.bat -call %iniWriteFileName% - -call :finishMessage -goto :eof - - -:finishMessage -echo. -echo Done. -echo. -pause -goto :eof - - -:end -exit \ No newline at end of file diff --git a/src/.gitignore b/src/.gitignore deleted file mode 100644 index 9fc955d..0000000 --- a/src/.gitignore +++ /dev/null @@ -1 +0,0 @@ -iniwrite.ini \ No newline at end of file diff --git a/src/initest.ini b/src/initest.ini deleted file mode 100644 index 8d06a32..0000000 --- a/src/initest.ini +++ /dev/null @@ -1 +0,0 @@ -myKey=myValue \ No newline at end of file diff --git a/src/iniwrite.bat b/src/iniwrite.bat deleted file mode 100644 index f40148a..0000000 --- a/src/iniwrite.bat +++ /dev/null @@ -1,24 +0,0 @@ -set delim== -set iniWriteFile=iniwrite.ini - -set key1=myKey1 -set key2=myKey2 -set value1=myValue1 -set value2=myValue2 - -call :create -call :addPair %key1% %value1% -call :addPair %key2% %value2% -goto :eof - - -:create -del %iniWriteFile% -echo.> %iniWriteFile% -goto :eof - - -:addPair -set line=%~1%delim%%~2 -echo %line%>> %iniWriteFile% -goto :eof \ No newline at end of file diff --git a/test/iniReadWriteTest/.gitignore b/test/iniReadWriteTest/.gitignore new file mode 100644 index 0000000..d1cf45c --- /dev/null +++ b/test/iniReadWriteTest/.gitignore @@ -0,0 +1 @@ +test.ini \ No newline at end of file diff --git a/test/iniReadWriteTest/ReadMe.md b/test/iniReadWriteTest/ReadMe.md new file mode 100644 index 0000000..1a4ebd6 --- /dev/null +++ b/test/iniReadWriteTest/ReadMe.md @@ -0,0 +1 @@ +Run `test.bat` by double-clicking on it and follow instructions. \ No newline at end of file diff --git a/test/iniReadWriteTest/footer.bat b/test/iniReadWriteTest/footer.bat new file mode 100644 index 0000000..f3d76bf --- /dev/null +++ b/test/iniReadWriteTest/footer.bat @@ -0,0 +1,5 @@ +echo. +echo Done. +echo. +pause +goto :eof \ No newline at end of file diff --git a/test/iniReadWriteTest/test.bat b/test/iniReadWriteTest/test.bat new file mode 100644 index 0000000..71d6eaa --- /dev/null +++ b/test/iniReadWriteTest/test.bat @@ -0,0 +1,135 @@ +REM Order of this test: +REM 1. Initialize. +REM 2. Write to .ini. +REM 3. Read from .ini. +REM 4. Compare written and read values. + +REM Initialize variables. +:initialize +@echo off +call :set_dirs +call :set_fileNames +call :set_vars +goto start + + +REM Sets paths for the directories used. +REM call :set_dirs +:set_dirs +set rootDir=..\.. +set toolsDir=tools +goto :eof + + +REM Sets names for the files used. +REM call :set_fileNames +:set_fileNames +set iniName=test.ini +goto :eof + + +REM Sets variables for reading and writing. +REM call :set_vars +:set_vars +set key1=myKey1 +set key2=myKey2 +set writeValue1=myValue1 +set writeValue2=myValue2 +set readValue1= +set readValue2= +goto :eof + + +REM Script is supposed to start here. +REM Go here when initialization has completed. +:start +cls +echo Testing reading and writing of .ini files. +echo Are you ready? +echo. +pause +call :write +call :read +call :compare +goto end + + +REM Write to .ini. +REM call :write +:write +cls +echo Writing to ini. +echo. +call %rootDir%\%toolsDir%\iniNew.bat %iniName% +call :write_single %key1% %writeValue1% +call :write_single %key2% %writeValue2% +call footer.bat +goto :eof + + +REM Writes a single key-value pair to .ini. +REM call :write_single [key] [value] +:write_single +set key=%~1 +set value=%~2 +echo Writing "%key%=%value%" to %iniName% +call %rootDir%\%toolsDir%\iniAdd.bat %iniName% %key% %value% +goto :eof + + +REM Read from .ini. +REM call :read +:read +cls +echo Reading from %iniName% +echo. +call :read_single %key1% readValue1 +call :read_single %key2% readValue2 +call footer.bat +goto :eof + + +REM Reads a single line from .ini. +REM call :read_single [key] [read value output] +:read_single +set keyName=%~1 +echo Looking for %keyName% +call %rootDir%\%toolsDir%\iniRead.bat %iniName% %keyName% readValue +echo Read value: %readValue% +set %~2=%readValue% +goto :eof + + +REM Compare written and read values. +REM call :compare +:compare +cls +echo Comparing values. +echo. +call :compare_single %writeValue1% %readValue1% +call :compare_single %writeValue2% %readValue2% +call footer.bat +goto :eof + + +REM Compare a single pair of written-read values. +REM call :compare_single [written value] [read value] +:compare_single +set writeValue=%~1 +set readValue=%~2 +echo Written: %writeValue%, read: %readValue% +if %readValue%==%writeValue% (echo OK) else (echo Values are not equal!) +goto :eof + + +REM Exits program. +:end +call :cleanup +exit + + +REM Remove temporary files. +REM call :cleanup +:cleanup +if exist %iniName% del %iniName% +goto :eof \ No newline at end of file diff --git a/tools/iniAdd.bat b/tools/iniAdd.bat new file mode 100644 index 0000000..b077249 --- /dev/null +++ b/tools/iniAdd.bat @@ -0,0 +1,6 @@ +REM Sets key-value pair +REM call addPair [file name] [key] [value] +set delim== +set line=%~2%delim%%~3 +echo %line%>> %~1 +goto :eof \ No newline at end of file diff --git a/tools/iniNew.bat b/tools/iniNew.bat new file mode 100644 index 0000000..97eb24f --- /dev/null +++ b/tools/iniNew.bat @@ -0,0 +1,6 @@ +REM Creates a new blank file with the specified name +REM call iniNew.bat [file name] +set fileName=%~1 +if exist %fileName% del %fileName% +echo.> %fileName% +goto :eof \ No newline at end of file diff --git a/src/iniread.bat b/tools/iniRead.bat similarity index 100% rename from src/iniread.bat rename to tools/iniRead.bat diff --git a/tools/placeholder b/tools/placeholder deleted file mode 100644 index e69de29..0000000 From 151cc4d573acdad76b4e313b75595772839347e7 Mon Sep 17 00:00:00 2001 From: Krumuvecis <66279792+Krumuvecis@users.noreply.github.com> Date: Tue, 12 Apr 2022 19:17:36 +0300 Subject: [PATCH 09/12] demo placeholder --- demo/HelloWorld/todo.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 demo/HelloWorld/todo.md diff --git a/demo/HelloWorld/todo.md b/demo/HelloWorld/todo.md new file mode 100644 index 0000000..9169de8 --- /dev/null +++ b/demo/HelloWorld/todo.md @@ -0,0 +1 @@ +this is a placeholder for a hello world project using this framework \ No newline at end of file From a4a93deb9776c721f373d074c1bf015be38e98d9 Mon Sep 17 00:00:00 2001 From: Krumuvecis <66279792+Krumuvecis@users.noreply.github.com> Date: Tue, 12 Apr 2022 19:17:48 +0300 Subject: [PATCH 10/12] file type ideas --- doc/files.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 doc/files.md diff --git a/doc/files.md b/doc/files.md new file mode 100644 index 0000000..ed7f47f --- /dev/null +++ b/doc/files.md @@ -0,0 +1,29 @@ +# File type info + +Proposed file types (ideas): +* General: + * `.list` - a list of strings + * a list of strings placed in separate lines + * doesn't count empty lines + * gotta think about comments within + * maybe the standard `//`? + * maybe `;`, etc at the beginning of line? + * `.map` - a map of key-value pairs + * primarily for saving values of actual objects' parameters + * can be used for other purposes as well + * `.class` - a class file + * parent object reference + * references to `.list` + * primitive variables list + * object reference list + * references to maps (see below) + * for constants + * for static variables + * for methods +* For handling objects: + * a folder for keeping static class definitions + * a folder for keeping object instances + * a ledger for keeping track of object instances + * and maybe relations? +* For future reference: + * `.vob` - visual object-batch \ No newline at end of file From 7f137f8ec122235f3d1e63398a8b775d7c1711a9 Mon Sep 17 00:00:00 2001 From: Krumuvecis <66279792+Krumuvecis@users.noreply.github.com> Date: Tue, 12 Apr 2022 21:49:54 +0300 Subject: [PATCH 11/12] ignore local sandbox --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 39497a3..7dd746d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -# Put ignorables here \ No newline at end of file +# Put ignorables here +sandbox/ \ No newline at end of file From a9e6d8f704fbaf538fcd9ec12b3aa490d13e7cd2 Mon Sep 17 00:00:00 2001 From: Krumuvecis <66279792+Krumuvecis@users.noreply.github.com> Date: Tue, 12 Apr 2022 21:52:00 +0300 Subject: [PATCH 12/12] src placeholder --- src/placeholder | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/placeholder diff --git a/src/placeholder b/src/placeholder new file mode 100644 index 0000000..e69de29