1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Missing Operator in Batch Script

Discussion in 'Software Development' started by Th3Angel, Dec 17, 2011.

Thread Status:
Not open for further replies.
  1. Th3Angel

    Th3Angel Thread Starter

    Joined:
    Oct 1, 2010
    Messages:
    2
    Hey guys,
    I'm creating a batch script to find the time between an action. I'll be mainly using this script as a custom batch compiler for the language PAWN. I'm not that great of an expert when it comes to DOS Batch Programming, but I manage my ways. This batch file was working before and suddenly started printing out "Missing Operator." just today.

    Code:
    @echo on
    
    FOR /f "tokens=1-4 delims=:.," %%T IN ( "%TIME%" ) DO (
    set /a StartTime=100%%T %% 100*360000+100%%U %% 100*6000+100%%V %% 100*100+100%%W %% 100
    )
    
    "C:\Users\James\Desktop\PAWN Compiler\pawncc.exe" "%1" -; -(
    
    
    FOR /f "tokens=1-4 delims=:.," %%T IN ( "%TIME%" ) DO (
    SET /a FinishTime=100%%T %% 100*360000+100%%U %% 100*6000+100%%V %% 100*100+100%%W %% 100
    )
    
    SET /a FinishTime=%FinishTime%-%StartTime%
    SET /a FinishTime=%FinishTime%*10
    
    echo Compile time: %FinishTime% ms
    
    The line that prints out "Missing Operator." are:
    Code:
    set /a StartTime=100%%T %% 100*360000+100%%U %% 100*6000+100%%V %% 100*100+100%%W %% 100
    --
    SET /a FinishTime=100%%T %% 100*360000+100%%U %% 100*6000+100%%V %% 100*100+100%%W %% 100
    
    Any helpful tips would be greatly appreciated. Thanks!
    James

    Edit: Hmm, it seems to be working today. What a weird feat.
     
  2. Squashman

    Squashman Trusted Advisor

    Joined:
    Apr 4, 2003
    Messages:
    19,786
    Save yourself a line of code.
    Code:
    set /a FinishTime=(%FinishTime%-%StartTime%)*10
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1031598

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice