last day (15 days later) » 

4:29 PM
2
A: Saving variables in a text file

TiwYour code will lead to problem, better change to: @echo off set /a number=1 >text.txt echo %number% Another way of the last line is: echo %number% 1>text.txt 1 means STDOUT, that's why your code won't write 1 to the file text.txt. And to read the file into variable1: set /p variable1=<t...

 
Good answer, so +1. I may use the >filename echo something syntax in the future instead of the parenthesis. Also, you don't need to add 1>test.txt. Not sure if this will save some milliseconds :). If you just try to create a batch file where you will only put the line echo testing>test.txt (without @echo off). Run this from cmd. You will see echo testing 1>test.txt. That's why I believe it is useless. But it doesn't bite, so you may include it :).
 
Tiw
@double-beep Thanks. However you miss the point, OP's doing echo %variable%>file, when the variable is 1 or 2 or so, it will end up with wrong behaviours, that's why I use that.
 
You can do echo %variable% >file, but that will echo a space, so you are actually right. That's why I use parenthesis.
 
Tiw
@double-beep Yeah parenthesis is a good idea.
 
@GerhardBarnard which comments? I usually fail to express what I am thinking in English and expressing incorrectly. But I think you don't want that, right?
@RichardLucin your error message was unexpected this time: no '>' found in Tiw's code. Did you mess up the symbols?
 
Tiw
4:29 PM
@RichardLucin FYI, when you at someone, better use TAB to finish the name. There's no > in that line, check above lines in your code, see if you made another error.
 
Yes, but here in comments, not editing your question @RichardLucin.
Have you used \ in set /p @RichardLucin? Also, you should check my and it was me answers!
 
Tiw
@RichardLucin Comment out/delete @echo off, open cmd first and run the batch file in it, then check the error, notice where it happened. Try produce Minimal, Complete, and Verifiable example.
 
@RichardLucin replace %~dp0` with %~dp0` where presented. If you haven't closed the parenthesis in if below, then close them immediately after set /p lang=….... If this didn't work, remember to quote set /p like: set /p "lang=<setting.gsf".
 
Tiw
@RichardLucin The same error? Apart from newlines, does your code look the same as you commented?
 
@RichardLucin in comments. Put it in pastebin (the whole code or at least the whole if statement) and send us the link.
 
Tiw
4:29 PM
@double-beep FYI: set /p "lang=<setting.gsf" is not gonna working, if you want to use quotes, you need to use it this way: set /p "lang="<"setting.gsf". However, I think when reading file quotes is not needed :)
@RichardLucin Try the changes I updated in the answer. Also echo.>"%~dp0settings.gsf" this only write a newline to the file, is this what you wanted?
 
Perhaps he meant to create a new file. There are plenty ways to do that. I don't think the best one is with echo.
Oh, wait! A custom flag should have been raised for a mod to move comments to chat. @RichardLucin or Tiw, can you move the discussion to chat? I can't.
 
Tiw
@double-beep I can't, seems the auto-move function is not triggered by this situation. I think it's okay this though, just when it's done clear 'em up.
Huh, just after my last comment, you did it.
 
yeah, so now waiting for @RichardLucin? Or he can't chat? Yeah, he is >20 rep :)
 
Tiw
I deleted my comments.
I don't know. Maybe this way even if he don't have 20 rep he can come?
Just wait him show up, either on comment or here :)
 
BTW, the error message seems strange @Tiw. Even if the files doesn't exist he had to get:
> The system can't find the file specified
 
Tiw
4:37 PM
Agree, there must be other problems / mistakes.
 
Also, @Tiw what I meant with set /p "var=<file" was actually set /p var=<file
 
Tiw
Okay :)
@user11103234 Hi
Can you type here?
 
That's actually @RobertLucin, and because <20 he appears with that icon.
 
Tiw
If not, then just edit your question add more details. Or paste your code on pastebin or somewhere, and comment the link for us.
You didn't close your else block.
@user11103234
 
4:58 PM
@RobertLucin you should be able to chat.
 
Tiw
Maybe need rejoin or even need some cache-refreshing time.
 
Tiw
I mean the site's caching. Or syncing between its servers/idns.
Anyway, seems it's solved.
Seems OP's gone, maybe busying toying with his code now. Nice talking with you, see you :)
 
bye, rollbacked since the whole code was not required.
 
Tiw
Yeah, that's better. Bye.
 

last day (15 days later) »