From: Zaidy036@air.isp.spam   
      
   On 7/15/2021 6:47 AM, Kenny McCormack wrote:   
   > In article ,   
   > JJ wrote:   
   >> On Wed, 14 Jul 2021 07:19:03 -0700 (PDT), Peter wrote:   
   >>> I was updating a batch file I wrote to backup one of my PCs. It kept   
   >>> crashing at a certain point. For two days I tried various things to fix   
   >>> it with no luck. I finally guessed at a fix which does work but I dont   
   >>> understand what the problem was or why the fix works. Here are a few   
   >>> lines from the batch file showing the original version.   
   >>>   
   >>> (Its basically a counter/timer loop. When the counter hits 5 seconds it   
   >>> exits the loop and continues elsewhere in the batch file. Its the   
   >>> bottom line that caused the crash.)   
   >>>   
   >>> =================================   
   >>> :wait-Z   
   >>> if %counter%==5 goto Start-N   
   >>> timeout 1 > nul   
   >>> set /A counter=%counter%+1   
   >>> if not exist z:\transfer\batch goto wait-Z   
   >>> =================================   
   >>   
   >> The `if` command would generate a syntax error if `%counter%` is   
   >> empty/blank.   
   >   
   > Yes, but that's not the line OP says is causing the problem.   
   >   
   > OP says the "bottom" line caused the crash, and the bottom line is:   
   >   
   >>> if not exist z:\transfer\batch goto wait-Z   
   >   
   > Further commentary in the OP makes it clear that that line (the one that   
   > ends with "wait-Z" is, indeed, the line that is causing the problem.   
   >   
   > In any case, I think we should assume that OP knows what he is doing with   
   > the "counter" variable, although it would, of course, be safer to test via:   
   >   
   > if X%counter%==X5 goto Start-N   
   >   
   > (Or any of the other standard batch file hacks that have arisen over the   
   > years to deal with this issue...)   
   >   
      
   use if %counter% EQU 5 goto Start-N   
   since not text but numerical   
      
   Does :wait-Z exist?   
      
   Also I would never use a goto target with something similar to batch   
   commands but rather add "_" to front of it or something more logical to   
   human reader.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|