2017-07-11 6 views
0

Ich fühle mich ziemlich dumm, als ich versuche, ein großes langes Programm im Batch zu programmieren, und ich habe gerade entdeckt, wie wenig ich eigentlich über die Sprache weiß. Eine Sache, die ich in vielen vorgeschlagenen Lösungen gesehen habe, sind Befehle wie set und dann /p oder etwas Ähnliches. Bisher habe ich /p, /a und /i gesehen. Ich habe Fragen gesehen, die fragen, wofür sie stehen, und ich weiß ein wenig darüber, was /p tut, aber was machen all diese, und gibt es noch weitere /(letter) Befehle, über die ich Bescheid wissen sollte?Was ist der Unterschied zwischen "/ p," "/ a" und "/ i" in Batch?

+0

Ein Befehl hat spezifische Schalter für sich. Es gibt keine "SET/I". Sie können die Hilfe für einen Befehl lesen, indem Sie den Befehlsnamen gefolgt von/eingeben. an der Eingabeaufforderung cmd. 'set /?' – Squashman

+0

Verwenden Sie in der Eingabeaufforderung * commandname * /? für die Dokumentation. Manchmal ist es ein wenig stumpf - schauen Sie es sich mit Hilfe der Suchfunktion in der oberen Leiste hier bei SO an. 'set' setzt normalerweise eine Variable auf einen String-Wert. 'set/a' setzt den Wert auf das Ergebnis einer Berechnung. 'set/p' akzeptiert eine Benutzereingabe als den Wert, der zugewiesen werden soll. 'set/i' - das ist noch nicht vorgekommen - es ist nicht offiziell dokumentiert. Wo hast du es gefunden? – Magoo

+0

Einige empfohlene Lektüre: https://ss64.com/nt/ – SomethingDark

Antwort

0

Aus den Ergebnissen der help set:

The /A switch specifies that the string to the right of the equal sign 
is a numerical expression that is evaluated. The expression evaluator 
is pretty simple and supports the following operations, in decreasing 
order of precedence: 

    ()     - grouping 
    ! ~ -    - unary operators 
    */%    - arithmetic operators 
    + -     - arithmetic operators 
    << >>    - logical shift 
    &     - bitwise and 
    ^     - bitwise exclusive or 
    |     - bitwise or 
    = *= /= %= += -= - assignment 
     &= ^= |= <<= >>= 
    ,     - expression separator 
If you use any of the logical or modulus operators, you will need to 
enclose the expression string in quotes. Any non-numeric strings in the 
expression are treated as environment variable names whose values are 
converted to numbers before using them. If an environment variable name 
is specified but is not defined in the current environment, then a value 
of zero is used. This allows you to do arithmetic with environment 
variable values without having to type all those % signs to get their 
values. If SET /A is executed from the command line outside of a 
command script, then it displays the final value of the expression. The 
assignment operator requires an environment variable name to the left of 
the assignment operator. Numeric values are decimal numbers, unless 
prefixed by 0x for hexadecimal numbers, and 0 for octal numbers. 
So 0x12 is the same as 18 is the same as 022. Please note that the octal 
notation can be confusing: 08 and 09 are not valid numbers because 8 and 
9 are not valid octal digits. 

The /P switch allows you to set the value of a variable to a line of input 
entered by the user. Displays the specified promptString before reading 
the line of input. The promptString can be empty. 

Soweit ich weiß gibt es keine/I-Schalter auf dem set Befehl.

Verwandte Themen