home bbs files messages ]

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

   alt.msdos.batch.nt      Fun with Windows NT batch files      68,980 messages   

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

   Message 67,343 of 68,980   
   JJ to All   
   GOTO and non existant label   
   05 Dec 18 04:16:24   
   
   From: jj4public@vfemail.net   
      
   How to prevent the batch file from abruptly terminated if `goto` is executed   
   with a non existing label?   
      
   I know that I can simply refactor the code, but it's a last resort.   
      
   e.g.   
      
   set /p "num=input task number: "   
   goto task%num%   
   rem this line is never executed if label doesn't exist   
   echo invalid task number   
   goto :eof   
      
   :task1   
   echo task1...   
   goto next   
      
   :task2   
   echo task2...   
   goto next   
      
   :next   
   echo further tasks...   
      
   --- 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