"missing operator" error message while using the "set /a" command
batch-file, parameters, set
Solution
A simple echo on could help here :-)
In your line set /a line number=%linenumber%+1 is a space linenumber, that is a problem.
Another thing, it is not neccessary to use
set /a linenumber=%linenumber% +1
It is better to use
set /a linenumber=linenumber+1
or
set /a linenumber+=1
Problem
Ok so ive been finishing off my batch program called "stringparsing.bat" and the last error im having trouble with is one that says "missing operator" when i use the following snippet: ``` set /p linecount= cls set foo=0 set linenumber=0 :lineset set /a linenumber=%linenumber% +1 set /p line1= %linenumber% echo %line1% >> %name%.txt set /a foo=%foo%+1 set /a line number=%linenumber%+1 IF %foo%==%linecount% goto MAIN123 goto lineset ``` More specificly, ive narrowed it down to : ``` set /a linenumber=%linenumber% +1 set /p line1= %linenumber% ``` Im pretty sure im mis-using the set /p command... what i am trying to do, is make a prompt that asks the user to input how many lines of text that they are going to insert into a text file. Then make a loop that asks the user to type some text which is then sent to the text file. But i wanted to to put the line number before the prompt so that it would look like this: So when the batch file asks for the first line, it says 1: , and when it asks for the second line, its says 2: , and so on. after each line prompt, i get the "missing operator" error message... Btw i need to use this scirpt to get it to work: set /p line1= %linenumber%+1 But in order to use this command with the +1 at the end, do i have to add the /a parameter as well as the /p parameter? Any ideas?