Cov txheej txheem:

Tsis Yog Li Qeb Batch Tutorial: 6 Kauj Ruam
Tsis Yog Li Qeb Batch Tutorial: 6 Kauj Ruam

Video: Tsis Yog Li Qeb Batch Tutorial: 6 Kauj Ruam

Video: Tsis Yog Li Qeb Batch Tutorial: 6 Kauj Ruam
Video: independence day #independenceday #india #youtubeshorts #shorts #indianflag 2024, Kaum ib hlis
Anonim
Tsis Yog Li Qub Batch Tutorial
Tsis Yog Li Qub Batch Tutorial

Hauv qhov kev qhia yav dhau los peb tau kawm txog qhov tseem ceeb ntawm kev sau cov ntaub ntawv batch. Yog tias koj tsis muaj qhov qhia meej tias pawg yog dab tsi, tab sis xav kawm nws, xa mus rau "Kev Qhia Ua Ntej Batch yooj yim heev". Hauv qhov kev qhia no koj yuav kawm paub ntau cov lus txib thiab yuav ua li cas siv lawv los tsim daim ntawv thov.

Kauj Ruam 1: Cov Kauj Ruam Hloov (1/3)

Variables yog yam uas yuav hloov pauv thaum peb tsim qhov sib txawv, peb tab tom tsim qee yam uas peb xav kom lub khoos phis tawj nco txog peb, qee yam uas peb tuaj yeem siv tom qab ntawm qhov program; peb muab lub computer rau tus nqi uas peb xav khaws thiab peb muab nws daim ntawv lo khaws cia hauv qab. peb tuaj yeem tsim cov lej thiab cov hlua siv cov lej sib txawv. Txhawm rau tsim qhov sib txawv koj yuav tsum kawm SET cov lus txib. SET lub npe = nyob zoo lub npe 'yog lub npe ntawm qhov sib txawv, thiab' nyob zoo 'yog qhov sib txawv tau khaws cia tam sim no txhua lub sijhawm koj ntaus "echo name" nws yuav tsum hais "nyob zoo" yog? Yog koj xav pom qhov txawv koj yuav tsum tso cov feem pua (%) cov cim nyob ib puag ncig nws. Yog li ntawd yog tias koj ntaus "ncha%test%" thiab nws yuav tsum hais "nyob zoo" yog? YOG

Kauj Ruam 2: Kauj Ruam (2/3)

Kauj Ruam (2/3)
Kauj Ruam (2/3)

Yog li tam sim no muaj tseeb peb tuaj yeem ua lej? Peb ntaus tus lej = 1 Qhov no tsim qhov sib txawv hu ua "num" nrog tus nqi 1 txuas rau nws.setset num =%num%+1 (qhov no txhais tau tias peb coj "num" (aka 1) thiab ua kom nws suav+1 (aka 1+1)) thenecho %num %nws yuav tsum muab rau peb 2, puas yog? cia peb sim nws: ntaus cov hauv qab no hauv notepad thiab txuag ua MathAttempt.bat (tsis suav nrog cov hnub qub (*)) @echo offset v = 1set v =%v%+1echo%v%pauseit yuav tsum hais 2, yog? NOPE.it hais tias 1+1 vim tias lub computer txhais koj cov lus txib raws li: koj: "yog li tus lej = 1, yog?" pc: "yog" koj: "yog li dab tsi yog tus lej ntxiv rau ib?" pc: num+1 = 1+1 yog li lub computer txhais koj cov lus txib.

Kauj Ruam 3: Kauj Ruam (3/3)

Kauj Ruam (3/3)
Kauj Ruam (3/3)

Yog li peb yuav ua li cas thiaj ua kom lub computer xav txog lej? Yooj yim, peb ntxiv /a ua ntej lub npe hloov pauv Piv txwv li: peb ntaus "teeb /tus lej = 1" tom qab ntawd "teeb tsa /tus lej =%num%+1" ces "ncha" %num%"ces peb yuav tsum tau 2, puas yog? cia peb sim nws sau qhov no rau hauv notepad ….blah blah blah, koj paub qhov laum. ********************* ******************************@echo offset /a num = 1set /a num =%num%+1echo%num% ncua ********************************************************* *** muaj! nws ntxiv 1+1! qhov no yog lub khoos phis tawj pom nws li cas: _you: yog li tus lej = 1, puas yog? pc: rightyou: yog li tus lej ntxiv ib? pc: num+1 = 1+1 = 2Voila! Yog li tam sim no cia ua ib qho kev suav suav! peb yuav siv cov lus txib goto uas peb tau kawm txog hauv Kev Qhia Zoo Tshaj Plaws. ***************************** ****************************@echo offset /tus lej = 1: topset /a num =%num%+1echo%num% mus saum ******************************************************** ********** Lub khoos phis tawj tau ntxiv 1, tom qab ntawd mus rau saum thiab ntxiv 1 ntxiv thiab lwm yam.

Kauj Ruam 4: Parameter Step (1/2)

Parameter Kauj Ruam (1/2)
Parameter Kauj Ruam (1/2)

Yog li tam sim no peb tuaj yeem siv qhov hloov pauv yog dab tsi yog tias peb muaj kev xaiv xaiv, xws li: nias 1 kom hais Hello.press 2 hais Goodbye. We siv "IF" hais kom ua, piv txwv li: Ntaus qhov no hauv koj li CMD: yog 1 = = 1 echo Saib nws ua haujlwm! (==) txhais tau tias "sib npaug", koj kuj tuaj yeem ntaus "EQU") Peb tau txais cov lus hais tias "Saib nws ua haujlwm!" Tam sim no ntaus qhov no: yog 1 == 2 echo Nws Ua Haujlwm! Peb tsis pom dab tsi vim tias 1 tsis sib npaug 2If peb xav tos tus neeg siv los tso qee yam hauv peb ntxiv a /p thiab tawm ib feem tom qab qhov sib txawv tsis muaj qhov zoo ib yam li no: set /p variablename = Qhov ntawd txhais tau tias lub khoos phis tawj yuav tos koj tso rau hauv ib yam dab tsi.so peb ntaus: ************************************* *@ncha offset v1 = nyob zoo !! teeb tsa v2 = bye !! ncho Nias 1 hais HI! echo Nias 2 hais BYE! teeb /p koj = yog %koj %== 1 ncha %v1 %yog %koj %= = 2 echo %v2 %pause ************************************** Qhov no yog qhia rau lub computer tias yog peb ntaus 1, nws yuav tsum ncha HI !, thiab yog tias peb hais 2 nws yuav tsum ncha BYE !!

Kauj Ruam 5: Parameters Kauj Ruam (2/2)

Parameter Kauj Ruam (2/2)
Parameter Kauj Ruam (2/2)

Yog li tam sim no peb paub tias yog peb xav xaiv qhov sib txawv peb ntaus: set /p variablename = thiab yog tias peb xav teeb tsa qhov sib txawv, peb ntaus: set /a variablename = value Yog li tam sim no vim li cas thiaj tsis ua qhov haujlwm me me uas suav rau thiab los ntawm 2000? Peb yuav siv SET, IF thiab GOTO hauv txoj haujlwm no (thiab pom tseeb ncha) ************************************ *****@echo offset /tus lej = 0: topset /a num =%num%+1echo%num%yog%num%== 2000 goto gobackgoto top: gobackset /a num =%num%-1echo%num %yog %num %== 0 goto topgoto goback ************************************** Yog li tam sim no, thaum nws mus txog 2000, IF hais kom ua nws GOTO ntu thib ob uas ua rau nws suav qis, tom qab ntawd thaum nws mus txog 0, nws yuav GOTO thawj ntu uas ua rau nws suav … etc thiab lwm yam

Kauj ruam 6: Ua tau

Koj tau ua tiav kuv cov lus qhia ua ib pawg. Koj tuaj yeem mus rau ntawm no mus rau lwm qhov kev qhia rau qee qhov Cool Batch ApplicationsIf koj xav tau kev pab nrog ib qho ntawm koj cov haujlwm Batch, xa kuv lossis xa email rau kuv ntawm [email protected] thiab Kuv yuav sim pab koj. Yog tias koj xav sim qee yam offline, Kuv pom zoo kom Kawm Kawm Batch File Programming! los ntawm John Albert, yooj yim heev, ua raws tau yooj yim thiab zoo yog tias koj xav tau kom zoo dua!

Pom zoo: