|"Do the !'s around the i make it a variable that changes each for loop?|
so that the useable variables with my information can be now used in my program
like: echo x1 x2 x3
and it would say something like: 670654 JEFF MS"
"Also would it be easier if I stored the data in the txt file with commas between
each variable instead of having them each on a new line?"
Well, reconsidering, I probably went wrong on that idea. You could, but you need to select a delimiter that won't be used in text, which can be difficult. As you pointed out, a comma might be used. You could try more obscure delimiters, but crlf is probably your best bet. A "one-line-per-file" format needs to be formatted in order to work, and that limits total of all fields to 80 bytes before you get wrapping (which confuses the output somewhat). This all depends on the sizes of your fields. The formatting could be suited to each field using another set of vars (f/e: name limit 10, comment limit 30, id limit 5)
"Should i create another variable for the last name?"
As always, that depends ;-) on how you are using the data, and how specific or "formal" you want your system to be.
It's not so much "batch" considerations involved. That's just the "gears and springs". What you need to design is the overall, well, design. "Comment" can be anything, but how long, and what allowable char.s?, "Service" is strict and easily validated, timestamp should be automatic, but what format do you want? (ie readable vs more accurate: 8:04 PM vs 20:04:53.28). Then the user-id, which should be validated in some way, and normally would be tied in to a username file which would eliminate the user having to enter (or mis-enter) his name each time.
You picked a fairly ambitious project for your early batch experience!
As for the specific commands, "USE THE QUESTION-MARK, LUKE!"
at command prompt:
etc. etc. Almost all commands have the help feature, so use it!
If you don't use "tokens=*" (or, "delims=") then the variable will only collect up to the first space or tab in the data, and all else will be either discarded or assigned to subsequent var.s.
Here is a rewrite I did (slow night), with comments, that tries to illustrate some points, lets you experiment, and will give you material for further investigation amd questions:
::====== begin script
:: set field sized for each item
ECHO --- MAIN MENU ---
ECHO (1) VIEW QUEUE
ECHO (2) CHECK IN
ECHO (3) COMPLETE SERVICE
ECHO (X) EXIT
SET /P M=:
:: this shortens up the code some
for %%a in (1 2 3 x) do if /i %M% equ %%a goto :%M%
:: note: case is ignored for labels, :X same as :x, at least on xp
ECHO --- CHECK IN ---
::clear junk: i learned the hard way, set/P RETAINS content if user
:: hits [ENTER]. It does not become null, so always clear var. before set/p
SET /P MEMBERNUMBER=MEMBER NUMBER:
SET /P NAME=MEMBER NAME:
SET /P SERVICE=SERVICE (MS/TA/SL):
SET /P COMMENT=COMMENT:
:: made this a sub (whenever redundant code content, usually good to make as sub)
ECHO IS THIS CORRECT?
SET /P C=(Y/N)
:: IF /I will ignore case, so user can type Y or y
IF /I %C% EQU Y (
::================ WRITE DATA ==============
REM:: SAVE MEMBER INFO TO FILE ON G HERE ::
REM and this is a good way to do multiple writes (saves re-opening the file
REM as well as code-space re-iterating the filename)
REM override any user-input. They should not have ctrl of timestamp.
REM although we could easily verify it with the file's timestamp.
REM advise to avoid "!" due to enabledelayedexpansion option
ECHO *** MEMBER CHECKED IN ***
:: and this looks "neater"
PAUSE > nul
SET /P CHANGE=WHAT? ( NUM, NAME, SERV, COMT, [ENTER]=DONE )
IF NOT DEFINED CHANGE GOTO :CORRECT1
:: quotes always a good idea around var.s in IF due to " " (space) possibility.
IF /I "%CHANGE%" EQU "NUM" SET /P MEMBERNUMBER=MEMBER NUMBER:
IF /I "%CHANGE%" EQU "NAME" SET /P NAME=MEMBER NAME:
:: just a suggestion: dis-allow timestamp modification, since users can abuse it...
:: not to mention formatting/parsing/validation nightmares
:: I would have it set automatically at "GO"-time (file-write-event)
::IF /i "%CHANGE%" EQU "TIME" SET /P TIMEIN=TIME IN:
IF /I "%CHANGE%" EQU "COMT" SET /P COMMENT=COMMENT:
IF /I "%CHANGE%" EQU "SERV" SET /P SERV=SERVICE:
SET /P C=OK? (Y,else..):
IF /i "%C%" EQU "Y" GOTO :CORRECT1
ECHO MEMBER NUMBER: %MEMBERNUMBER%
ECHO MEMBER NAME: %NAME%
ECHO TIME IN: %TIMEIN%
ECHO SERVICE: %SERVICE%
ECHO COMMENT: %COMMENT%
REM ::you need "tokens=*" or "delims=" to get all data past the space
FOR /F "TOKENS=*" %%T IN ('TIME /T') DO SET TIMEIN=%%T
echo service %service%
for /f "tokens=*" %%a in ('dir /b /o:d *.TXT') do (
for /f "tokens=*" %%b in (%%a) do (
:: wait for viewing
set /p null=...
set /a c+=1
set z=%z% :
::set each colunm into n-space field, only works with delayedexpansion