Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# Put ignorables here
# Put ignorables here
sandbox/
4 changes: 3 additions & 1 deletion ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ This is an attempt of *OOP* using `.bat` and `.ini` files.

## Functionality

None.
`.ini` file reading (`src\iniread.bat [file name] [key name] [output value]`)

See `src\test.bat` for new functionality.

## Notes

Expand Down
1 change: 1 addition & 0 deletions demo/HelloWorld/todo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
this is a placeholder for a hello world project using this framework
29 changes: 29 additions & 0 deletions doc/files.md
Original file line number Diff line number Diff line change
@@ -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
Empty file added src/placeholder
Empty file.
1 change: 1 addition & 0 deletions test/iniReadWriteTest/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test.ini
1 change: 1 addition & 0 deletions test/iniReadWriteTest/ReadMe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Run `test.bat` by double-clicking on it and follow instructions.
5 changes: 5 additions & 0 deletions test/iniReadWriteTest/footer.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
echo.
echo Done.
echo.
pause
goto :eof
135 changes: 135 additions & 0 deletions test/iniReadWriteTest/test.bat
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions tools/iniAdd.bat
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions tools/iniNew.bat
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions tools/iniRead.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
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