home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   alt.msdos.batch      Fun with MS-DOS batch files      42,547 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 41,065 of 42,547   
   Nick to foxidrive   
   Re: [MSDOS7] if ".echo off"==".echo off"   
   24 Dec 14 12:07:39   
   
   From: nickoffsmailbox@gmail.com   
      
   On Wednesday, 24 December 2014 20:41:12 UTC+8, foxidrive  wrote:   
   > On 24/12/2014 18:57, Nick wrote:   
   > > Hello. I had planned to use the following 'SET /P' check in a batch file I   
   > > intend to be used on both 9x and NT systems until I tested it on Windows   
   > > 98SE (a Windows Virtual PC VM running on Windows 7 x64 should it matter)   
   >   
   > Do you need to test if Windows 95 is running to branch elsewhere in your   
   code?   
   >   
   > What do you actually need to do?   
      
      
   -Do you need to test if Windows 95 is running to branch elsewhere in your code?   
      
   It's actually an exercise in almost the opposite; trying to make a simple   
   "Windows neutral" batch file as compatible as reasonably possible with   
   both 9x and NT based systems without bogging it down with unnecessary OS   
   checks, and potentially limiting or flawed assumptions based on such checks.   
      
   For example, for single key input for a simple options menu, I don't want to   
   skip the test for "choice" based on an assumption that a suitable version of   
   the command doesn't exist on the users system because it didn't when it was   
   first installed. Hell, "choice" could be a debug code filled batch file some   
   geek has knocked up for all I care - if it's on the command path and returns   
   the expected errorlevel then all's good and well.   
      
   I also don't want to limit that possibility when testing for and using choice.   
   Sure I could check for the two likely variants found on Windows (one of which   
   requires /M for a prompt and strips quotes, the other chokes on /M and   
   preserves   
   quotes) but I figure I'd just use the common syntax (/C:xyz) and echo my own   
   prompt when required. No lose in functionality, less code, and far easier on   
   the eye and brain imo.   
      
   In that sense I plan to be as accomodating as I can but I'm not fixated about   
   catering to one and all and every case. So for user input I test for CHOICE,   
   then test for SET /P, then, on the off chance we're still rolling, I tell that   
   random bum still using vanilla NT4 of the benefits of downloading almost any   
   version of 'choice' - otherwise fall thru to the menu...   
      
     ECHO 5 | CALL CHOICE /C:12345   
     CLS   
     IF ERRORLEVEL 5 IF NOT ERRORLEVEL 6 SET INPUTCMD=GETKEY   
     IF ".%INPUTCMD%"==".GETKEY" GOTO:MENU   
      
     SET INPUTCMD=   
      
     SET>nul <%0 /P INPUTCMD=Test if SET waits for user input...   
     CLS   
     IF NOT "%.INPUTCMD%"=="@.ECHO OFF" GOTO:HELP   
      
     SET INPUTCMD=GETSTRING   
      
     :MENU   
     ...   
     ...   
     GOTO %INPUTCMD%   
      
   -What do you actually need to do?   
      
   What I'm wanting to do with the code I posted is to test if 'SET' handle the /P   
   switch, i.e. is able to create a variable, and assign a users input as it's   
   value. The test method I chose was to redirect the batchfile to SET, then check   
   if it managed to save the first line of the batchfile (@ECHO OFF) to a variable   
   and branch away if it couldn't.   
      
   What it looks like I need to do is change the first line of the batchfile to a   
   string with no whitespace or find some way to redirect some other know string   
   into SET /P.   
      
      
   On a different note, it's the 25th here in (not yet) sunny Perth W.A.   
   Safe and happy merries to you (and you all).   
      
   Cheers,   
   Nick   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca