0

I'm trying to save user input variables from a batch file into a text file. So that some javascript can read the file to use the variables.

This is what I have so far:

:varecho
echo %GAMEPIN% > variables.txt
echo %NICKNAME% >> variables.txt
goto launch

This just writes "ECHO is off" into the variables.txt:

How would I get the contents of the variables into the file?

  • If you edit your question to format the script correctly it will be easier to answer. I can't tell what the line breaks are supposed to be. – Jon G - Megaphone Tech Dec 10 '16 at 6:51
  • 2
    Right now you're overwriting the contents of the file with each echo. You should use >> in order to append to the file. If you want to read the file later on with javascript ... why are you not reading the input using javascript in the first place? In addition your code is incomplete, there is no label defined launch. – Seth Dec 10 '16 at 8:48
  • I just updated the ">" to ">>" for the second echo command, and also the formatting seems to be correct not, (not sure if for everyone). The reason I don't get the user input from Jscript in the first place is because I don't know it and I had the batch file already made, except batch isn't capable of the most important part of what i was making so I got a friend to write up some JScript that could do it, I just need this problem solved before I can implement it, Thanks for any help. – Stanly Dec 10 '16 at 20:09
0

I would assume your %GAMEPIN% or %NICKNAME% variables are empty.

When you use "echo" with nothing by it's side, or an empty variable, you get a response whether the echo is on or off.

As seen here, I declare an empty variable, and when I echo it, since it's empty, it just tells me if echo is on or off.

I get response ECHO is on/off

Thus, make sure your variables are properly declared.

| improve this answer | |
  • Well actually the variables, I think, are previously filled because when you open the file it asks for user input of these variables, does that not save the input into them? – Stanly Dec 10 '16 at 20:03
  • You'll have to show us the code you use to populate the variables. For the moment, it appears that these variables are empty, resulting in the output you describe. – Larryc Apr 15 at 7:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.