

InterviewSolution
Saved Bookmarks
1. |
Solve : Help creating files? |
Answer» <html><body><p>I'm writing a messenger for me and my brother to use at our house. I'm Just having a little trouble with it.<br/><br/>Here's what I have so far,<br/><br/> Code: <a>[Select]</a>ECHO OFF<br/><br/>IF EXIST Writer.bat (<br/> IF EXIST <a href="https://interviewquestions.tuteehub.com/tag/reader-771315" style="font-weight:bold;" target="_blank" title="Click to know more about READER">READER</a>.bat (GOTO <a href="https://interviewquestions.tuteehub.com/tag/done-958312" style="font-weight:bold;" target="_blank" title="Click to know more about DONE">DONE</a><br/> ) ELSE (<br/> GOTO Reader<br/> )<br/> ) ELSE (<br/> GOTO Writer<br/>)<br/><br/>:Reader<br/><br/>ECHO ECHO OFF>Reader.bat<br/>ECHO.>>Reader.bat<br/>ECHO :Loop>>Reader.bat<br/>ECHO.>>Reader.bat<br/>ECHO CLS>>Reader.bat<br/>ECHO <a href="https://interviewquestions.tuteehub.com/tag/type-238192" style="font-weight:bold;" target="_blank" title="Click to know more about TYPE">TYPE</a> Messages.txt>>Reader.bat<br/>>>Reader.bat ECHO TIMEOUT /t 2<br/>ECHO GOTO Loop>>Reader.bat<br/><br/>ATTRIB +H Reader.bat<br/><br/>ECHO Reader Successfully Created.<br/><br/>IF EXIST Writer.bat (GOTO Done<br/> ) ELSE (<br/> GOTO Writer<br/>)<br/><br/>:Writer<br/><br/>ECHO ECHO OFF>Writer.bat<br/>ECHO.>>Writer.bat<br/>ECHO ECHO Enter your name:>>Writer.bat<br/>ECHO SET /p User="">>Writer.bat<br/>ECHO.>>Writer.bat<br/>ECHO :Loop>>Writer.bat<br/>ECHO.>>Writer.bat<br/>ECHO CLS>>Writer.bat<br/>ECHO ECHO Enter your message:>>Writer.bat<br/>ECHO SET /p Message="">>Writer.bat<br/>>>Messages.txt ECHO ECHO %%User%% - %%Message%%>>Writer.bat<br/>>>Messages.txt ECHO ECHO.>>Writer.bat<br/>ECHO GOTO Loop>>Writer.bat<br/><br/>ATTRIB +H Writer.bat<br/><br/>ECHO Writer Successfully Created.<br/><br/>IF EXIST Reader.bat (GOTO Done<br/> ) ELSE (<br/> GOTO Reader<br/>)<br/><br/>:Done<br/><br/>PAUSE<br/>START Reader.bat<br/>START Writer.bat<br/>EXIT<br/>The parts I'm having troubles with is:<br/><br/> Code: <a>[Select]</a>>>Writer.bat ECHo ECHO %%User%% - %%Message%%>>Messages.txt<br/>>>Writer.bat ECHO.>>Messages.txt<br/>And:<br/><br/> Code: <a>[Select]</a>>>Reader.bat ECHO TIMEOUT /t 2<br/>The first one I really wasn't expecting to work, does anybody know a way around it?<br/><br/>And the second, I really don't know why it's not working. Any Ideas?<strong>>>Reader.bat ECHO TIMEOUT /t 2</strong> No problems with this line, it appears it will be written to Reader.bat but does Timeout have a /t switch?<br/><br/> Code: <a>[Select]</a>>>Writer.bat ECHO ECHO %%User%% - %%Message%%>>Messages.txt<br/>>>Writer.bat ECHO.>>Messages.txt<br/>Escape the second >> using the caret like<br/> Code: <a>[Select]</a>>>Writer.bat ECHO ECHO %%User%% - %%Message%%^>^>Messages.txt<br/>>>Writer.bat ECHO ECHO.^>^>Messages.txt<br/>This doesn't mean your script will run, I think there are other problems for you to sort out..<br/><br/>FYI to save a lot of repetitive typing you could use<br/><br/>(<br/>ECHO ECHO OFF<br/>ECHO ECHO.<br/>ECHO SET /p User=Enter your name: <br/>ECHO ECHO.<br/>etc...<br/>.<br/>.<br/>etc...<br/>)>writer.bat<br/><br/>Good luck.Ahh, thank you very much!<br/><br/>I am aware of the bugs, and am still working on them. These two were the ones stumping me.<br/><br/>And by the way:<br/><br/> Code: <a>[Select]</a>C:\>timeout /?<br/><br/>TIMEOUT [/T] timeout [/NOBREAK]<br/><br/>Description:<br/> This utility accepts a timeout parameter to wait for the specified<br/> time period (in seconds) or until any key is pressed. It also<br/> accepts a parameter to ignore the key press.<br/><br/>Parameter List:<br/> /T timeout Specifies the number of seconds to wait.<br/> Valid range is -1 to 99999 seconds.<br/><br/> /NOBREAK Ignore key presses and wait specified time.<br/><br/> /? Displays this help message.<br/><br/>NOTE: A timeout value of -1 means to wait indefinitely for a key press.<br/><br/>Examples:<br/> TIMEOUT /?<br/> TIMEOUT /T 10<br/> TIMEOUT /T 300 /NOBREAK<br/> TIMEOUT /T -1<br/><br/>C:\><br/>Thanks for the suggestions!<strong>Timeout /t</strong> <a href="https://interviewquestions.tuteehub.com/tag/sorry-648642" style="font-weight:bold;" target="_blank" title="Click to know more about SORRY">SORRY</a> about that, it's your Win 7 vs my Win XP. LOL Haha yeah, not a problem! Thanks again. Quote from: Dusty on <a href="https://interviewquestions.tuteehub.com/tag/august-385421" style="font-weight:bold;" target="_blank" title="Click to know more about AUGUST">AUGUST</a> 17, 2010, 09:28:32 PM</p><blockquote>FYI to save a lot of repetitive typing you could use<br/><br/>(<br/>ECHO ECHO OFF<br/>ECHO ECHO.<br/>ECHO SET /p User=Enter your name: <br/>ECHO ECHO.<br/>etc...<br/>.<br/>.<br/>etc...<br/>)>writer.bat<br/><br/>Good luck.<br/></blockquote> WOW! You can actually do that? Dang...that could have saved tonnes of time! Quote from: helpmeh<blockquote>WOW! You can actually do that?</blockquote> <br/>Yep, try it out.<br/><br/></body></html> | |