vendredi 6 novembre 2020

Can't understand why this Batch file is not going through to the IF statement

I'm still relatively new to Batch scripting and I'm trying to get familiarized with it through this implementation of a small idea. I am still unaware if the variables will carry out whatsoever from one IF statement to the other or if indentation is allowed. Hence why I added this with regards to trying to solve the variables being carried out:

SETLOCAL enabledelayedexpansion

Declaration of variables:

SET /a val1=10
SET /a val2=2
SET /a val3=3
SET /a val4=1
SET /a val5=2

SET /a eval1=10
SET /a eval2=2
SET /a eval3=4
SET /a eval4=2
SET /a eval5=1

SET next=F
SET who=F

SET round=0
SET /a val6=0

PAUSE

The program seems to be encountered after the PAUSE command with the introduction of the IF statements. I tried putting PAUSE throughout the code however these were completely disregarded. With no error message whatsoever.

General Logic:

:loop1

IF %val1% NEQ 0 set next=T
IF %eval1% NEQ 0 set next=T
IF "%next%"=="T" (

    SET /a ran=%random% %%6 +1
    SET /a ran2=%random% %%6 +1

    step1 = %ran%+%val3%
    estep1 = %ran2%+%eval3%

    IF %step1% GEQ %estep% SET who=You(
        
    :loop

    SET /a ran3=%random% %%6 +1
    SET /a ran4=%random% %%6 +1
    SET /a ran5=%random% %%6 +1
    SET /a ran6=%random% %%6 +1

        IF "%who%=="F"(
        estep2 = %ran3%+%eval4%
        step2 = %ran4%+%val3%

            IF %estep2% GEQ %step2%(
            estep3 = %ran5%+%eval5%
            step3 = %ran6%+%val2%
                
                IF %estep3% GEQ %step3(
                SET /a eval6=%random% %%4 +1 
                estep4 = %eval6%+%eval4%
                step4 = %val1%-%estep4% 
                
                round = %round% +1  
                GOTO loop1
                ) ELSE (
                    SET who=You
                    GOTO loop)  
            ) ELSE(
                SET who=You
                GOTO loop)              
            
        )       

        IF "%who%"=="You"(
        step2 = %ran3%+%val4%
        estep2 = %ran4%+%eval3%

            IF %step2% GEQ %estep2%(
            step3 = %ran5%+%val5%
            estep3 = %ran6%+%eval2%
                
                IF %step3% GEQ %estep3(
                SET /a val6=%random% %%4 +1 
                step4 = %val6%+%val4%
                estep4 = %eval1%-%step4%    
                
                round = %round% +1  
                GOTO loop1
                ) ELSE (
                    SET who=You
                    GOTO loop)
                
            ) ELSE(
                SET who=F
                GOTO loop)
        )
    )   
) ELSE (
    IF %eval1% EQU 0 (
            val6= %val6%+%round%
            IF %val6% EQU 10(
                val1 = %val1% +3
                val2 = %val2%+1
                val3 = %val3%+1
                val4 = %val4%+1
                val5 = %val5%+1
                ECHO "Level Up"
            )
            ECHO "Good Job")
    IF %val1% EQU 0 (ECHO "Oof")

PAUSE

Aucun commentaire:

Enregistrer un commentaire