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,344 of 68,980   
   Herbert Kleebauer to All   
   Re: GOTO and non existant label   
   05 Dec 18 11:02:39   
   
   From: klee@unibwm.de   
      
   On 05.12.2018 10:01, JJ wrote:   
      
   > Well, that's the same as refactoring which I'm trying to avoid. The question   
   > is how to prevent the abrupt batch termination, if it's even possible. It's   
   > not how to prevent the GOTO command to be called with non existing label.   
      
   I don't understand what you want to do.   
      
      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   
      
   As I interpret your code, if an invalid task number   
   is given, you want to terminate the batch anyhow, the   
   only difference is to output "invalid task number".   
      
   If this is all you want, call the batch from a parent   
   batch and dependent on the return code, echo the   
   error message.   
      
   --- 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