Save and load custome settings.

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
MLGsuperGame414
Posts: 54
Joined: 10 Nov 2011 20:40

Save and load custome settings.

#1 Post by MLGsuperGame414 » 15 Nov 2011 18:35

Hey, I dont know where to start with this one. I want to add a settings option to my program and make it so you can save your custom settings. Color/Font/Size ect. Is there any right way to go about this?

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

Re: Save and load custome settings.

#2 Post by Ed Dyreen » 15 Nov 2011 19:36

'

Code: Select all

if not exist "config.CMD" >"config.CMD" (
   echo.set "this=option"
   echo.set "that=option"
) &call "config.CMD"

MLGsuperGame414
Posts: 54
Joined: 10 Nov 2011 20:40

Re: Save and load custome settings.

#3 Post by MLGsuperGame414 » 15 Nov 2011 20:00

That simple? Is there anyway to have the user custom name it?

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

Re: Save and load custome settings.

#4 Post by Ed Dyreen » 15 Nov 2011 20:16

'
That depends, do you want an interactive script ?

Code: Select all

set /p "$config.file=enter filename or press enter:" ||set "$config.file=config"
set     "$config.file=%$config.file%.CMD"
if not exist "%$config.file%" >"%$config.file%" (
   echo.set "this=option"
   echo.set "that=option"
) &call "%$config.file%"

MLGsuperGame414
Posts: 54
Joined: 10 Nov 2011 20:40

Re: Save and load custome settings.

#5 Post by MLGsuperGame414 » 15 Nov 2011 20:19

Well not really, Just a simple menu for example that I can save and re-load with a browser


Saving it
:Settings
Choose Color:
Choose Font:
Saving...
Ect

Loading it
Choose file to load:
Displays a file in the folder called CSSettingFile.bat

I know how to make the menu just not sure how to go about for coding.

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

Re: Save and load custome settings.

#6 Post by Ed Dyreen » 15 Nov 2011 20:34

'
how about:

Code: Select all

@echo off &setlocal enableExtensions enableDelayedExpansion

:main ()
::(
   call :load "()"
   echo.hello world
   pause
   call :save "()"
::)
exit /b 0

:load ()
::(
   cls
   dir /b /a:-d
   echo.
   set /p "$cfg.file=Enter filename to load:"    ||goto :load "()"
   call "!$cfg.file!"             ||goto :load "()"
::)
exit /b 0

:save ()
::(
   set /p "$cfg.file=Enter filename to save:"    ||goto :save "()"
   set /p "$color=Choose Color:"          ||goto :save "()"
   set /p  "$font=Choose font:"          ||goto :save "()"
   >"!$cfg.file!" (
      echo.set "$color=!$color!"
      echo.set  "$font=!$font!"
   )
::)
exit /b 0

MLGsuperGame414
Posts: 54
Joined: 10 Nov 2011 20:40

Re: Save and load custome settings.

#7 Post by MLGsuperGame414 » 15 Nov 2011 20:41

See here is the problem I am still new to this and don't know what most of that means haha. I think I am ahead of myself at the moment.

Post Reply