![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-25 23:43 |
47,812 topics / 349,910 posts / today 0 new / 48,264 members |
| DOS批处理 & 脚本技术(批处理室) » [Discussion] Comparison between Batch Scripts and Programming Languages |
| Printable Version 6,157 / 26 |
| Floor1 lxmxn | Posted 2006-11-16 03:33 |
| 版主 Posts 4,938 Credits 11,386 | |
|
I have been learning batch processing for some time. I feel that batch processing scripts have many things in common with many programming languages, especially in algorithms. The algorithms from other programming languages can also be applied to batch processing. Of course, it is only the similarity in algorithms, and the actual statements are different. ^_^ In my personal opinion, batch processing scripts have the following aspects in common with other programming languages (compared with the familiar C language): --------------------------------------- Variable assignment In batch processing, you can use the set command to assign values, while in C language, it is assigned like "int a=1". Judgment statement In batch processing, you can use if to judge, and similarly, in C language, you also use if. Loop statement In batch processing scripts, you can use for to implement the loop function (of course, there are many other methods to implement loops in batch processing~), which is similar to the for in C. Input statement In C language, you can use the "Scanf()" function to implement input operations, while in batch processing, you can use "set /p a=" instead. Output statement In C language, you can use the "Printf()" function to implement output operations, and in batch processing, you can use a simple "echo" statement to complete it. Function In C language, you can call functions to directly complete some tasks. I think that the combination of the "call" and "goto" commands in batch processing with labels is equivalent to a "function". You can first write the functions to be implemented in batch processing, then save the code in a.bat file or.cmd file, or directly put it in the batch processing script that calls it, and then call it with "call" or "goto", which is not equivalent to a function? =_= Parameter In C language, there are parameters, and batch processing files and commands can also accept various parameters. Algorithm Many algorithms are similar. --------------------------------------- The above are just my humble opinions. Due to experience and various reasons, there are inevitable omissions and errors. Everyone is welcome to discuss, criticize, and correct. If there are other common points that I haven't mentioned, everyone can post to discuss, and I will improve the content of the original text. Maybe some friends think that one is a script and the other is a programming language, and the two cannot be compared. And the purpose of me writing this article is to make everyone have a new understanding of batch processing, that's all. [ Last edited by lxmxn on 2006-11-16 at 03:34 AM ] |
|
| Floor2 electronixtar | Posted 2006-11-16 03:39 |
| 铂金会员 Posts 2,672 Credits 7,493 | |
Personally, I think this is just a sub, that is, a procedure. A function needs to return a value. And Goto can only exchange values through a public variable |
|
| Floor3 lxmxn | Posted 2006-11-16 03:48 |
| 版主 Posts 4,938 Credits 11,386 | |
Personally, I think this is just a sub, that is, a procedure. A function returns a value. And Goto can only exchange values through a public variable Well, there are still many differences, but the general functions are like that, both can be called to implement some functions. |
|
| Floor4 vkill | Posted 2006-11-16 04:11 |
| 金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽 | |
|
They are all similar, just different commands
|
|
| Floor5 anakin | Posted 2006-11-20 04:40 |
| 新手上路 Posts 4 Credits 1 | |
|
Not bad.....all pretty much the same
|
|
| Floor6 kxows | Posted 2006-11-20 05:53 |
| 初级用户 Posts 11 Credits 31 | |
| Floor7 hxuan999 | Posted 2006-11-23 07:38 |
| 中级用户 Posts 161 Credits 337 | |
|
Not bad. Should write code to compare.
|
|
| Floor8 yunlin | Posted 2006-11-25 15:48 |
| 新手上路 Posts 7 Credits 5 | |
|
Don't understand
First time here Newcomer Got your back, honey |
|
| Floor9 kaidi | Posted 2007-01-27 11:02 |
| 新手上路 Posts 8 Credits 16 | |
|
Study study again and again
|
|
| Floor10 ccwan | Posted 2007-01-27 21:23 |
| 金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊 | |
|
I quite agree with the LZ's opinion that there are many commonalities among computer languages.
For the request from the 7th floor to write code as an example, here I respectively give an example in C language and batch processing, which can well illustrate the problem. C language code: Batch processing code: It is not difficult to see from the above example that the problem-solving ideas are the same, and even the codes are very similar. |
|
| Floor11 TLang | Posted 2007-01-27 22:48 |
| 初级用户 Posts 21 Credits 46 | |
|
Can batch processing be used for operations?!
|
|
| Floor12 zh159 | Posted 2007-01-27 22:52 |
| 金牌会员 Posts 1,467 Credits 3,687 | |
Originally posted by TLang at 2007-1-27 09:48: set /a Of course, with certain limitations |
|
| Floor13 TLang | Posted 2007-01-27 23:27 |
| 初级用户 Posts 21 Credits 46 | |
Originally posted by zh159 at 2007-1-27 09:52: Yes, just basic operations The IF statement is also relatively simple ...... In short, personally, I feel that in the WinXP SP2 era, although there have been great expansions to command-line commands and batch commands, they are still relatively simple and basic. |
|
| Floor14 lxmxn | Posted 2007-01-28 11:55 |
| 版主 Posts 4,938 Credits 11,386 | |
Originally posted by TLang at 2007-1-27 10:27: Hehe, after all, it's a script. How can it have as many functions as high-level languages for you to use directly? |
|
| Floor15 redtek | Posted 2007-01-29 01:04 |
| 金牌会员 Posts 1,147 Credits 2,902 | |
|
Cannons, missiles, submachine guns... In war, none can be missing. Each has its own strengths and will be put to use in every place in war where its strengths need to be exerted~:)
For guns, I might never touch or use one in my whole life (and of course can't buy one, haha). But for some people, losing it means losing precious lives~:) Using the most suitable or suitable tools or scripts or a certain language in certain environments and making them give full play to their functions as much as possible is art~:) (Personal rambling, just for fun, although still dreaming of having a gun~:) |
|
| 1 2 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |