Re SagInvoker:
感谢SagInvoker兄对此问题的关注,并提出自己的宝贵意见。
首先需要声明,1楼提供的只是一个样例程序,而非一个通用程序,所以它无法缺省地处理用户的各种需求,而是需要用户根据自己的需求修改源代码。
程序中的主模块中已经注明转换序列可以重新设定和调整,言外之意是若将它应用在自己的项目中,需要根据自己的需求调整转换序列,大多数时候这项工作是必须的。我在文中使用的12345678和cdefghij只是一个带有很大局限性的示例而已。
但是,作为程序本身,应该要尽可能的考虑到各种经常会发生的情况,以增强它的适应性。比如实际情况中的转换序列很可能超过10个字符的长度(例如字母表向ASCII码表的转换)。而我在程序中使用到的环境变量#a2和#b2,正是为了解决长序列转换的问题。因为系统的环境空间是有限的,我们如果完全将转换序列计数为相应长度的环境变量,将造成环境空间的用度紧张,所以我将#a2和#b2设计为序列索引的十位数,而#a1和#b1则为个位数。那段你有疑问的代码,实现的是由#a1到#a2的进位运算,它在很多情形下都是需要的。
所以说,程序中的那段代码虽然在演示的过程中不会执行,但不代表他在所有的情况下都不会执行,即使这些另外的情况需要修改原来的代码。
当然,程序本身应该可以有进一步的改善,比如说他可以自我处理用户自定义的转换序列,而不需要用户去更改源代码。但是,作为一个带有示意性的项目来说,这些界面问题不属于我们关注的焦点,我们首先需要完成的是核心功能的实现,其次才能考虑界面和框架问题。
欢迎SagInvoker兄能对此程序进行完善,简化代码或者增加功能,都是可以的。
Re SagInvoker:
Thanks to Brother SagInvoker for paying attention to this issue and putting forward your valuable opinions.
First of all, it needs to be stated that the sample program provided on the first floor is just a sample, not a general-purpose program. Therefore, it cannot handle various user needs by default, but users need to modify the source code according to their own needs.
The conversion sequence can be reset and adjusted in the main module of the program. In other words, if it is applied to your own project, you need to adjust the conversion sequence according to your own needs. Most of the time, this work is necessary. The 12345678 and cdefghij I used in the text are just examples with great limitations.
However, as for the program itself, it should try to consider various frequently occurring situations as much as possible to enhance its adaptability. For example, the conversion sequence in actual situations may be longer than 10 characters (such as the conversion from the alphabet to the ASCII code table). The environment variables #a2 and #b2 used in my program are exactly to solve the problem of long sequence conversion. Because the system's environment space is limited, if we completely count the conversion sequence as environment variables of corresponding lengths, it will cause the environment space to be overused. So I designed #a2 and #b2 as the tens digit of the sequence index, and #a1 and #b1 as the units digit. The code you have doubts about realizes the carry operation from #a1 to #a2, which is needed in many situations.
So although the code in the program will not be executed during the demonstration, it does not mean that it will not be executed in all cases. Even if these other situations require modifying the original code.
Of course, the program itself can be further improved. For example, it can self-process user-defined conversion sequences without users having to change the source code. But as for a demonstrative project, these interface issues are not the focus of our attention. First, we need to complete the implementation of the core functions, and then we can consider the interface and framework issues.
Welcome Brother SagInvoker to improve this program. Simplifying the code or adding functions is all right.