Computing.Net > Forums > Programming > remember user inputs

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

remember user inputs

Reply to Message Icon

Name: Brock
Date: February 1, 2009 at 22:17:21 Pacific
OS: Windows XP
Subcategory: Batch
Comment:

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.



Sponsored Link
Ads by Google

Response Number 1
Name: wille
Date: February 2, 2009 at 03:36:04 Pacific
Reply:

would you like to store the input in a variable or a file?

Live the life as you know it
/ Wille


0

Response Number 2
Name: lee123abc
Date: February 2, 2009 at 06:34:06 Pacific
Reply:

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


0

Response Number 3
Name: brockey01
Date: February 2, 2009 at 16:22:51 Pacific
Reply:

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


0

Response Number 4
Name: brockey01
Date: February 2, 2009 at 21:04:34 Pacific
Reply:

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


0

Response Number 5
Name: brockey01
Date: February 3, 2009 at 09:27:21 Pacific
Reply:

help please . thank you !!


0

Related Posts

See More



Response Number 6
Name: lee123abc
Date: February 3, 2009 at 09:48:21 Pacific
Reply:

*** 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


0

Response Number 7
Name: brockey01
Date: February 3, 2009 at 21:23:22 Pacific
Reply:

anyone else care to help me? Thanks everyone


0

Response Number 8
Name: brockey01
Date: February 4, 2009 at 19:06:43 Pacific
Reply:

someone help please Thank you


0

Response Number 9
Name: lee123abc
Date: February 10, 2009 at 13:43:34 Pacific
Reply:

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.


0

Response Number 10
Name: brockey01
Date: February 20, 2009 at 21:06:23 Pacific
Reply:

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.


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: remember user inputs

Java - validating user input www.computing.net/answers/programming/java-validating-user-input/12223.html

hiding user input in java www.computing.net/answers/programming/hiding-user-input-in-java/9552.html

Hiding user input in a Batch File www.computing.net/answers/programming/hiding-user-input-in-a-batch-file/15928.html