remember user inputs

Brock February 1, 2009 at 22:17:21
Specs: Windows XP
How would i go about creating a batch that when a user enters data such as number and when they go back to enter more data and at the end of the day averages all the numbers.

i just need to know how to set up a batch to do a database or something to remember that the user says to the inputs to later on add or average those numbers entered.


See More: remember user inputs

Report •


#1
February 2, 2009 at 03:36:04
would you like to store the input in a variable or a file?

Live the life as you know it
/ Wille


Report •

#2
February 2, 2009 at 06:34:06
Here is a simple MENU system that will take your input (option 2) and at the end of the day you can use (option 3) to get the average.
then you can reset the numbers by using (option 1). Let me know what you think


@echo off
:menu
cls
echo 1 - Reset average number list
echo 2 - Enter new number
echo 3 - Get averages
echo 4 - Exit
set /p menu=
if %menu% == 1 type nul> numberkeep.log & echo Number list reset! & ping -n 1 -w 1000 1.1.1.1 >nul
if %menu% == 2 goto :number
if %menu% == 3 goto :average
if %menu% == 4 exit
goto :menu

:number
echo Please enter number
set /p number=
echo %number% >> numberkeep.log
goto :menu

:average
cls
setlocal enabledelayedexpansion
for /f "tokens=* delims=" %%j in (numberkeep.log) do (
set line=%%j
set /a answer + = !line!
set /a counter +=1
)

set /a final_answer =%answer%/%counter%
echo Your average is: %final_answer%
ping -n 3 -w 1000 1.1.1.1 >nul


Report •

#3
February 2, 2009 at 16:22:51
hey Thanks, would you explain the FOR command on what that does, also how could i go about doing that and maintaining a menu that needs to have things remembered.

im doing this for a family memeber that needs an option to remember

Carbs in take.
blood suger levels
water intake amounts.
and time and date done.

i just need to know now how to do it with more than one menu item.

but Thanks for the help

Brock


Report •

Related Solutions

#4
February 2, 2009 at 21:04:34
i also forgot to add doing that way is a good way that you should me but also on that last post how would i go about taking all that info on different items all in one printable report.

Thanks
Brock


Report •

#5
February 3, 2009 at 09:27:21
help please . thank you !!

Report •

#6
February 3, 2009 at 09:48:21
*** If anyone else comes up with a suggestion please come forward, as I will only be able to write something tomorrow***

Hi, sorry, just got home from work... I think we are in total opposite timezones.

(FOR) command:
If you look in START - RUN - type CMD.
Then type for /?

I understand it is difficult if you are new to batch, but I am not the best to explain it for you. In the case I used for you though it cycles through the document NUMBERKEEP.LOG which was created by the batch file I wrote. It goes through the file line by line, and in that example it sets each line as a variable. If you want more help maybe an expert can help you out!

I have some basic examples of FOR and IF etc. If you send me a private message I could send some to you.

I am busy with your request, but as I am not an expert it will take a while. My sister is a diabetic and really could have used something like this to help control her blood sugar levels.

Cheers until tomorrow Brockey01.
Lee


Report •

#7
February 3, 2009 at 21:23:22
anyone else care to help me? Thanks everyone

Report •

#8
February 4, 2009 at 19:06:43
someone help please Thank you

Report •

#9
February 10, 2009 at 13:43:34
For testing purposes (to make it easier for you) I have placed ‘rem’ in front of a line (7 lines from bottom)
Example: rem del numberblood.log & del numberblood_date.log & del numberblood_time.log

When you are ready to use the blood sugar level batch file properly just remove ‘rem’ from that line.

Basically…. every time you test your blood just enter the data in the menu (option 1)

Then enter the date and time as well…. then repeat this process throughout the day.

ONLY USE OPTION 2 (GET AVERAGES FOR BLOOD) ONCE A DAY, OTHERWISE IF YOU DO IT EVERY TIME YOU WONT GET AN AVERAGE, AND EACH VALUE YOU ENTER WILL BE DELETED.

I also made it keep a history… so you can keep a monthly check on the levels. The history will be kept in a file called bloodprint-#.log This will never be over-written. Just do a few tests yourself and see!

I hope this is what you are looking for. I await your response and then I will start on the rest of the file.

The hard part is done and I can simply copy what I have done and edit it to complete the batch file.

Remember… this is not complete… still under construction… I await your response.
Cheers
Lee


@echo off & title Averages - version 1.5
::=================================================
-----------------
::=================================================
:MENU
cls
echo 1 - Blood Sugar Levels
echo 2 - Get Averages for Blood
echo 3 - Exit
set /p menu=
if %menu% == 1 goto :BLOOD
if %menu% == 2 goto :BLOOD_AVERAGE
if %menu% == 3 goto :EOF
goto :MENU
::=================================================
-----------------
::=================================================
:BLOOD
::=================================================
:ENTER_BLOOD
cls & echo.
echo Press M (and enter) at any time to return to main menu)
echo.
echo Please enter Blood Sugar Level
set /p blood=
if /i %blood% == m goto :menu
::=================================================
:ENTER_TIME
cls & echo.
echo Press M (and enter) at any time to return to main menu)
echo.
echo Please enter TIME that Blood Sugar Level was taken
echo (Format for time: 'hhmm' example: 08:30 = eight thirty in the morning)
set /p bloodtime=
set bloodtime_h=%bloodtime:~0,2%
set bloodtime_m=%bloodtime:~3,2%
if /i %bloodtime% == m goto :MENU
if %bloodtime_h% gtr 24 goto :TIME_ERROR
if %bloodtime_h% lss 0 goto :TIME_ERROR
if %bloodtime_m% gtr 60 goto :TIME_ERROR
if %bloodtime_m% lss 0 goto :TIME_ERROR
goto :ENTER_DATE
::=================================================
:TIME_ERROR
echo PLEASE SEE EXAMPLE TO ENTER TIME...
ping -n 3 -w 1000 1.1.1.1 >nul
goto :ENTER_TIME
::=================================================
:ENTER_DATE
cls & echo.
echo Press M (and enter) at any time to return to main menu)
echo.
echo Please enter DATE that Blood Sugar Level was taken
echo (Format for date: 'dd/mm/yy' example: 25/12/08)
set /p blooddate=
if /i %blooddate% == m goto :menu
set blooddate_d=%blooddate:~0,2%
set blooddate_m=%blooddate:~3,2%
set blooddate_y=%blooddate:~6,2%
if %blooddate_d% gtr 31 goto :DATE_ERROR
if %blooddate_d% lss 1 goto :DATE_ERROR
if %blooddate_m% gtr 12 goto :DATE_ERROR
if %blooddate_m% lss 1 goto :DATE_ERROR
if %blooddate_y% lss 01 goto :DATE_ERROR
goto :BLOOD_INFO_COMPLETE
::=================================================
:DATE_ERROR
echo PLEASE SEE EXAMPLE TO ENTER TIME...
ping -n 3 -w 1000 1.1.1.1 >nul
goto :ENTER_DATE
::=================================================
:BLOOD_INFO_COMPLETE
echo %blood% >> numberblood.log
echo %bloodtime%>> numberblood_time.log
echo %blooddate_d%:%blooddate_m%:%blooddate_y%>> numberblood_date.log
goto :BLOOD
::=================================================
-----------------
::=================================================
:BLOOD_AVERAGE
cls
set counter=
setlocal enabledelayedexpansion
for /f "tokens=* delims=" %%j in (numberblood.log) do (
set blood=%%j
set /a counter +=1
set blood!counter!=!blood!
set /a answer +=!blood!
)
set /a final_answer =%answer%/%counter%
echo Your average is: %final_answer%
goto :PRINT_BLOOD
::=================================================
-----------------
::=================================================
:PRINT_BLOOD
set numbercheck=1
:PRINT_BLOOD_START
if exist bloodprint-%numbercheck%.log set /a numbercheck +=1 & goto :PRINT_BLOOD_START
echo =====================================================>> bloodprint-%numbercheck%.log
echo =================BLOOD SUGAR LEVELS=================>> bloodprint-%numbercheck%.log
echo =====================================================>> bloodprint-%numbercheck%.log
echo.>> bloodprint-%numbercheck%.log
echo.>> bloodprint-%numbercheck%.log
echo bloodprint-%numbercheck%.log was printed on %date% at %time%>> bloodprint-%numbercheck%.log
echo.>> bloodprint-%numbercheck%.log
echo Blood Sugar Level Date Time>> bloodprint-%numbercheck%.log
oodprint-%numbercheck%.log
call :GET_ALL_BLOOD_INFO
oodprint-%numbercheck%.log
echo Average Blood level = %final_answer% >> bloodprint-%numbercheck%.log
echo end of print>> bloodprint-%numbercheck%.log
--- - - - - - - - - - ->> bloodprint-%numbercheck%.log
start bloodprint-%numbercheck%.log
goto :MENU
::=================================================
-----------------
::=================================================
:GET_ALL_BLOOD_INFO
::set blood variables
set blcount=100
setlocal enabledelayedexpansion
for /f "tokens=* delims=" %%j in (numberblood.log) do (
set blood2=%%j
set /a blcount +=1
set var!blcount!=!blood2!
)
::set blood_time variables
set btcount=200
setlocal enabledelayedexpansion
for /f "tokens=* delims=" %%j in (numberblood_time.log) do (
set bloodtime=%%j
set /a btcount +=1
set var!btcount!=!bloodtime!
)
::set blood_date variables
set bdcount=300
setlocal enabledelayedexpansion
for /f "tokens=* delims=" %%j in (numberblood_date.log) do (
set blooddate=%%j
set /a bdcount +=1
set var!bdcount!=!blooddate!
)
echo %var101% %var201% %var301%>> bloodprint-%numbercheck%.log
echo %var102% %var202% %var302%>> bloodprint-%numbercheck%.log
echo %var103% %var203% %var303%>> bloodprint-%numbercheck%.log
echo %var104% %var204% %var304%>> bloodprint-%numbercheck%.log
echo %var105% %var205% %var305%>> bloodprint-%numbercheck%.log
echo %var106% %var206% %var306%>> bloodprint-%numbercheck%.log
echo %var107% %var207% %var307%>> bloodprint-%numbercheck%.log
echo %var108% %var208% %var308%>> bloodprint-%numbercheck%.log
echo %var109% %var209% %var309%>> bloodprint-%numbercheck%.log
echo %var110% %var210% %var310%>> bloodprint-%numbercheck%.log
echo %var111% %var211% %var311%>> bloodprint-%numbercheck%.log
echo %var112% %var212% %var312%>> bloodprint-%numbercheck%.log
rem del numberblood.log & del numberblood_date.log & del numberblood_time.log
goto :END_CALL
::=================================================
-----------------
::=================================================
:END_CALL
::end call is simply the end of file, to end any call commands.


Report •

#10
February 20, 2009 at 21:06:23
Looks Great Lee, when i get a chance ill test this out, anyway you should add and option to average or just count also for count carbs, water amount drank, anyway this looks great.

Thanks
Brock

PM if you like to talk on board.


Report •


Ask Question