CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2014
    Posts
    1

    Help With Batch Code

    I'm working on a project for my son. I want to imitate the code for the matrix in CMD using a .bat file.
    ~note: this is an example of whats going on, not the whole code

    :start
    @set /a bottomlimit = 0
    @set /a upperlimit = 2
    @set /a result1 = %bottomlimit% + %random% %% (%upperlimit% - %bottomlimit% + 1)

    if %result1% == "2" set /a result1 = " " <- this is the part that is messing up, it doesnt change the 2 to a blank space and keeps echoing as 2

    echo %result1%

    goto start

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637

    Re: Help With Batch Code

    This is a Visual C++ forum.

  3. #3
    Join Date
    Nov 2003
    Posts
    1,902

    Re: Help With Batch Code

    If you want to compare strings, you need to make the left-hand-side a string as well. And don't use /a when not performing a arithmetic assignment. You should also remove the spaces around "=" in your set commands (I don't use any spacing anywhere).
    Code:
    if "%result1%" == "2" set result1=" "
    echo %result1%
    I like to use this site for reference: http://ss64.com/nt/

    gg

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured