Jump to content

Recommended Posts

Posted (edited)

.add and subtract parameters is a program that allows you to provide several numbers as parameters when running it.  Then, it adds or subtracts these numbers and shows you the result.

$totalparametros = $CmdLine[0]
$capturaroperacion = "nada"

MsgBox(0, "Bienvenidos a sumatorio", "El nombre del programa es:" & @ScriptName)

If $CmdLine[1] = "suma" Then
    $capturaroperacion = "Suma"
EndIf

If $CmdLine[1] = "resta" Then
    $capturaroperacion = "Resta"
EndIf

$totaloperacion = 0

For $i = 2 To $totalparametros
    If $capturaroperacion = "Suma" Then
        $totaloperacion = $CmdLine[$i] + $totaloperacion
    EndIf

    If $capturaroperacion = "Resta" Then
        If $i = 2 Then
            ; Si es el primer número en la resta, restar de 0
            $totaloperacion = $CmdLine[$i]
        Else
            ; Restar los números siguientes
            $totaloperacion = $totaloperacion - $CmdLine[$i]
        EndIf
    EndIf
Next

MsgBox(0, "numeros", $CmdLineRaw)
MsgBox(0, "operacion", $totaloperacion)

se debe utilizar el CMD

Edited by Jos
Please use English only!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...