China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-22 13:09
中国DOS联盟论坛 » 网络日志(Blog) » 【Billunique】Personal Blog - Drops Make an Ocean View 40,498 Replies 59
Floor 31 Posted 2007-04-26 01:38 ·  中国 北京 雅虎中国
中级用户
★★
菜鸟总动员
Credits 259
Posts 112
Joined 2006-08-28 15:53
19-year member
UID 61454
Status Offline
Who Can Tell Me where to upload pictures so that the link address doesn't change every day, so that when citing, it won't become invalid? I've tried Yahoo Spaces and Baidu Spaces, but they always change every day, which is very mechanical.

[ Last edited by Billunique on 2007-4-26 at 01:40 AM ]
★①②③④⑤⑥⑦⑧⑨⑩㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ【●】→←↑↓▲
Floor 32 Posted 2007-04-26 02:01 ·  中国 北京 雅虎中国
中级用户
★★
菜鸟总动员
Credits 259
Posts 112
Joined 2006-08-28 15:53
19-year member
UID 61454
Status Offline
%%Bus%%

  The so-called bus is a common channel for transmitting information among various functional components in a computer, and it is an important part of a microcomputer. They can be ribbon-shaped flat cables or extremely thin metal connections on a layer of a printed circuit board. All information is transmitted through the bus. According to the different contents and functions of the transmitted information, the bus can be divided into three categories:

  1. Address Bus AB (Address Bus): When accessing the memory or I/O port, it transmits the address information of the memory unit or I/O port to be accessed provided by the CPU, so as to select the memory unit or I/O port to be accessed. It is a one-way bus, and its width determines the size of the CPU's addressing space. For example, the 8086 has 20 address lines, so its addressing space is 2 to the power of 20 = 1MB. And the P4 has 36 address lines, so its addressing space is 2 to the power of 36 = 1GB * 2 to the power of 6 = 64GB.

  2. Data Bus DB (Data Bus): When fetching instructions from the memory or performing read/write operations on operands, and performing read/write operations on the I/O port, the instruction code or data information is sent to the CPU through the data bus or sent out by the CPU. It is a bidirectional bus. Its width determines the number of binary bits transmitted by the CPU at one time. (The number of bits of the processor usually referred to corresponds to it)

  3. Control Bus CB (Control Bus): Various control or status information is sent from the CPU to relevant components or from relevant components to the CPU through the control bus. The transmission direction of each line in the CB is fixed.

[ Last edited by Billunique on 2007-4-26 at 03:46 AM ]
★①②③④⑤⑥⑦⑧⑨⑩㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ【●】→←↑↓▲
Floor 33 Posted 2007-05-14 12:04 ·  中国 北京 雅虎中国
中级用户
★★
菜鸟总动员
Credits 259
Posts 112
Joined 2006-08-28 15:53
19-year member
UID 61454
Status Offline
I'm back! I've been really busy lately~ So busy that I neglected my studies, which isn't good. You know that knowledge needs to be reinforced; it has to be often remembered and used to become knowledge that benefits you.

Actually, my study of DOS is just at the surface, very superficial. Logically, I should delve deeper to achieve something. But limited by time and the current application environment, I don't want to start over again. I know that learning should have priorities and patience; I can't always just skim through things, but I always inadvertently make this mistake. Anyway, learning has to go on. What should I study next?

Accidentally entering electronixtar's post " Mixed Programming of Batch Processing and Other Languages" (http://www.cn-dos.net/forum/viewthread.php?tid=26819), a simple code in WIKI gave me some inspiration. Since I can't clearly define the learning goal right now, let's start with a trial. Let's make something relatively simple and commonly used - VBS, after all, Windows is everywhere. To learn VBS, start with the following code:

echo msgbox 3^>2 >v.vbs
cscript v.vbs


After execution, a Windows dialog box will pop up, with the main content showing "True" and an "OK" button. This is the benefit of being from the same Microsoft family, saving a lot of code.
★①②③④⑤⑥⑦⑧⑨⑩㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ【●】→←↑↓▲
Floor 34 Posted 2007-05-14 18:44 ·  中国 北京 雅虎中国
中级用户
★★
菜鸟总动员
Credits 259
Posts 112
Joined 2006-08-28 15:53
19-year member
UID 61454
Status Offline
A segment of code from a classic tutorial — an example of inserting VBS into an HTML page:

<HTML>
<HEAD>
<TITLE>Test Button Event</TITLE>
</HEAD>
<BODY>
<FORM NAME="Form1">
<INPUT TYPE="Button" NAME="Button1" VALUE="Click">
<SCRIPT FOR="Button1" EVENT="onClick" LANGUAGE="VBScript">
MsgBox "The button is clicked!"
</SCRIPT>
</FORM>
</BODY>
</HTML>
★①②③④⑤⑥⑦⑧⑨⑩㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ【●】→←↑↓▲
Floor 35 Posted 2007-05-16 15:52 ·  中国 北京 雅虎中国
中级用户
★★
菜鸟总动员
Credits 259
Posts 112
Joined 2006-08-28 15:53
19-year member
UID 61454
Status Offline
Regardless of everything, just write down these few paragraphs first: (quite inspiring)

Component-Based Development (abbreviated as CBD) is a product integrating various excellent design ideas and practices, such as object-oriented development, contract design, model-driven development, separate consideration, software system architecture design, etc. The goal of CBD is to improve the software development process, and the means is to assemble new software through some pre-built software components instead of developing from scratch. By emphasizing reuse, CBD achieves considerable development efficiency and quality. Delphi components, COM+ components, CORBA components, JavaBeans, and EJB, etc., are some well-known component models.

Components and controls:

In the.NET framework, a component refers to a class that implements the System.ComponentModel.IComponent interface, or a class directly or indirectly derived from a class that implements IComponent. In programming, the term "component" usually refers to an object that can be reused and can interact with other objects. The.NET framework components meet these general requirements and also provide functions such as controlling external resources and design-time support.

A control is a component that provides (or implements) user interface (UI) functions. The.NET framework provides two base classes for controls: one for client Windows Forms controls and the other for ASP.NET server controls. They are System.Windows.Forms.Control and System.Web.UI.Control. All controls in the.NET framework class library are directly or indirectly derived from these two classes. System.Windows.Forms.Control is derived from Component and itself provides UI functions. System.Web.UI.Control implements IComponent and provides a structure on which UI functions can be easily added.

A classic sentence: Every control is a component, but not every component is a control.

[ Last edited by Billunique on 2007-5-16 at 04:39 PM ]
★①②③④⑤⑥⑦⑧⑨⑩㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ【●】→←↑↓▲
Floor 36 Posted 2007-05-16 17:53 ·  中国 北京 雅虎中国
中级用户
★★
菜鸟总动员
Credits 259
Posts 112
Joined 2006-08-28 15:53
19-year member
UID 61454
Status Offline
### ☆Working Mechanism of VB Programs

Visual Basic is an object-based programming language. A Visual Basic program consists of numerous objects and code that responds to various events. When a user performs certain operations on an object, a specific event is generated. Objects can also automatically generate events under certain specific conditions. When an event occurs, the Visual Basic program automatically calls the corresponding code to handle these events. It can be said that during the running process of the application, it is always waiting for the occurrence of events and responding to them until the user ends the entire program.



Many people feel particularly difficult to understand as soon as they come into contact with the term "object-oriented". The word "thing" is commonly used in daily spoken language, and it can be simply considered that the "thing" mentioned here has the same meaning as the "object" here. An object is a very specific existing thing, such as a pencil, a generator, a tiger (if expressed in spoken language, these things are all "things"). It is not difficult to find that whether it is a pencil, a generator, or a tiger, they are all a thing with complete meaning: if a pencil is missing the lead core, it is no longer a pencil; if a generator is missing the magnetic core, it cannot generate electricity and thus cannot be called a generator.

In daily life, how to distinguish "things"? First, we classify things. Obviously, we will not confuse a home computer with a lathe because they belong to two different types of things. Then, for objects of the same type, different individuals can be distinguished by their different characteristics. For example, two pencils, they are all objects of the same type, but they may be distinguished by color: one is yellow and the other is red.

Thus, in the object-oriented theory, the term "class" is used to represent different types of objects, and attributes and methods are used to represent different characteristics of the same type of objects. Attributes are the static characteristics of an object. For example, color (this is static) is an attribute of a pencil. The color of a pencil can be black, red, or blue. Methods are the dynamic characteristics of an object. For example, generating electricity (this is an action, which is dynamic) is a method of a generator. The method of an object is triggered by an external event. For example, the power generation method of a generator will only be triggered and enter the power generation state after the operator allows the generator to operate.

In Visual Basic, forms, controls, menus, etc. are all objects. The objects used in the example program "Welcome to the VB World" are: one form, two command button controls, and one label control. (You can imagine it, here it follows the text in the book)

Take the command button control as an example. In the example program, two button controls are used. Although these two objects are both command buttons (that is, belong to the same class), they have different Caption attributes: one is "Start" and the other is "Exit". They also have different Name attributes: one is "Command1" and the other is "Command2". The command button control has many methods, such as the "move" method. When the position of the command button control on the form needs to be changed, we call the "move" method of the command button to achieve it.

Obviously, in Visual Basic programming, the user interface of the application is composed of many objects related to the user interface. Therefore, the first thing to do when writing a Visual Basic program is to prepare the objects to be used in the program. (Prepare "rice"--|thing|to go with rice)



The main body of a Visual Basic program is numerous objects, that is, forms, controls, menus, etc. When a user performs an operation on an object, such as a mouse click on a command button, a mouse click event will be triggered on this command button object. Generally speaking, the user's operations are purposeful, and the application should respond to the user's operations, that is, the programmer should write code to handle these events.

In fact, the running process of a Visual Basic program is the process of handling events. When the program runs, various different objects will generate many different events. Some of these events are caused by user operations, and others are generated by the object itself under certain conditions (such as the "timer time is up" event). Programmers write processing code for various events respectively. When no event occurs, the program does nothing. This is the so-called event-driven mechanism.

This event-driven mechanism based on objects in Visual Basic is a magic weapon for simplifying Windows program design. Under this mechanism, to design a Visual Basic program, you only need to follow the following steps:

1) Design the user interface of the program, that is, place various objects.
2) Define the attributes of each object in the user interface, such as color, title, etc.
3) Define each possible event to be used.
4) Write corresponding code for the events.

Among them, the first 3 steps are steps related to interface design. Programmers can complete these designs only by using VB's visual tools, and no code needs to be written at all. (Of course, it can also be written manually, and VBS has to be written manually) The 4th step is the coding work to realize the program function. In this way, programmers can focus most of their energy on the realization of functions. As for how the interface captures user operations, how to issue events, and how to call the event handling code written by the programmer, there is no need to care. VB has already designed these things for the user.

[ Last edited by Billunique on 2007-5-16 at 06:08 PM ]
★①②③④⑤⑥⑦⑧⑨⑩㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ【●】→←↑↓▲
Floor 37 Posted 2007-05-17 17:52 ·  中国 北京 雅虎中国
中级用户
★★
菜鸟总动员
Credits 259
Posts 112
Joined 2006-08-28 15:53
19-year member
UID 61454
Status Offline
### Process

A sub procedure is a block of program code used to accomplish a specific function. If there are multiple places in a program where the same program code is needed to do the same thing, this piece of code can be made into a procedure. When needed, the corresponding task can be completed by calling this procedure.

A function procedure is also a block of program code that can accomplish a specific function. The difference between it and a sub procedure is that a function can return a result.

Using procedures can make the program structure clear, thus achieving the design goals of structured and modular programming.
★①②③④⑤⑥⑦⑧⑨⑩㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ【●】→←↑↓▲
Floor 38 Posted 2007-05-25 10:38 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
Brother Billunique has a wide range of interests. If it were me, I couldn't handle it all at the same time. Hehe
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Floor 39 Posted 2007-05-29 15:01 ·  中国 北京 雅虎中国
中级用户
★★
菜鸟总动员
Credits 259
Posts 112
Joined 2006-08-28 15:53
19-year member
UID 61454
Status Offline
Ashamed, ashamed. Let Brother ccwan laugh at me! It's not that I have a wide range of knowledge, but just groping in the dark. When learning things, you must never be like me, with no specific focus and no particular expertise. Just like that classic cartoon "Digging Wells", dig a few times and then change place, and in the end, you never dig your own "well".
★①②③④⑤⑥⑦⑧⑨⑩㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ【●】→←↑↓▲
Floor 40 Posted 2007-05-29 18:47 ·  中国 北京 雅虎中国
中级用户
★★
菜鸟总动员
Credits 259
Posts 112
Joined 2006-08-28 15:53
19-year member
UID 61454
Status Offline
This passage is quite good:

Variables are like containers. A container can hold one liter of liquid or two liters of liquid, or it can hold nothing. It's the same with variables; they can hold a number, a string, and exactly what and how much to hold is entirely determined by the function of the program.

(From a professional perspective, a variable is a name that is stored in memory and represents the address of the information it contains. A variable is a code name.)
★①②③④⑤⑥⑦⑧⑨⑩㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ【●】→←↑↓▲
Floor 41 Posted 2007-06-05 10:21 ·  中国 北京 雅虎中国
中级用户
★★
菜鸟总动员
Credits 259
Posts 112
Joined 2006-08-28 15:53
19-year member
UID 61454
Status Offline
### Obtaining Input

Prompting for information is easy: Just use `InputBox`. This function pops up a dialog box, and users can happily enter whatever you asked them to.

```vb
ask = "Hey, what's your name?"
title = "Who are you?"

answer = InputBox(ask, title)
If answer = vbEmpty Then
MsgBox "You want to cancel? Fine!"
WScript.Quit
ElseIf answer = "" Then
MsgBox "You want to stay incognito, all right with me..."
Else
MsgBox "Welcome " & answer & "!"
End If
```

Note: When the user presses the "Cancel" key, the passed value is an "empty" value, which we can equate to the constant "VbEmpty". If this layer of judgment is not added and "Cancel" is directly submitted, the MsgBox will "try its best" to convert the "empty value" into an "empty string", so that the function of the "Cancel" key will not be reflected, and it will seem on the surface as if an empty string is passed.

You can use the following code to experience the above description.

```vb
ask = "Hey, what's your name?"
title = "Who are you?"
default = "??"

answer = InputBox(ask, title, default)
MsgBox "Welcome " & answer & "!"
```

[ Last edited by Billunique on 2007-6-14 at 11:01 AM ]
★①②③④⑤⑥⑦⑧⑨⑩㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ【●】→←↑↓▲
Floor 42 Posted 2007-06-05 18:20 ·  中国 北京 雅虎中国
中级用户
★★
菜鸟总动员
Credits 259
Posts 112
Joined 2006-08-28 15:53
19-year member
UID 61454
Status Offline
### Checking Input
Prompting for information doesn't necessarily mean you'll get it. You can ask politely, because InputBox accepts anything the user types in. Therefore, after asking for information, you should check the entered information to make sure it is valid. (Here we use the thing called "is~", which is equivalent to asking "Are you ~?")

```code
'asking for a date
ask="What's your birthday?"
title="Let's see how old you are!"

'start a loop:
Do
birthday=InputBox(ask,title)
'check whether the user wants to quit:
If IsEmpty(birthday)Then
MsgBox "Hey! You could always lie to me to hide " _
&" your age! But ok, I quit!"
WScript.Quit
ElseIf Not IsDate(birthday) Then
'check whether birthday is really a date!
'complain and give another chance:
MsgBox "You didn't enter a valid date! Try again!"
End If
'loop until a valid date was retrieved
Loop Until IsDate(birthday)

'at this point,we have a valid date,good!
'do some fun calculations:

age_in_days=DateDiff("d",birthday,Date)
age_in_months=DateDiff("m",birthday,Date)
age_in_years=DateDiff("yyyy",birthday,Date)
day_born=WeekdayName(Weekday(birthday))

' DateDiff is a function to compare the interval between two dates. The first parameter is the comparison unit, and the result is the value of the first date minus the second date.
' Weekday is a function that returns the "day of the week number" (Sunday~Saturday:1~7)
' WeekdayName is a function that returns the "day of the week name"

'calculate this year's birthday
date_day=Day(birthday)
date_month=Month(birthday)
'use current year:
date_year=Year(Date)

' Day function returns the "day of the month number" (1~31)
' Month function returns the "month number" (1~12)
' Year function returns the specific "year number" (in the format of 2007)
' DateSerial function accepts three parameters, which should be valid values or expressions of year, month, and day respectively,
' and then rearranges them into a standard date format containing year, month, and day

this_years_birthday=DateSerial(date_year,date_month,date_day)
'use Abs to convert to positive numbers in case the birthday's already over:
days_to_birthday=Abs(DateDiff("d",Date,this_years_birthday))
day_celebrating=WeekdayName(Weekday(this_years_birthday))

' Because it's previous parameter - subsequent parameter, there may be a negative value, that is, the birthday hasn't arrived yet,
' so use Abs (Absolute) to get its absolute value.

'already over?
If this_years_birthday<Date Then
message="you celebrated your birthday "& days_to_birthday &" days ago"
ElseIf this_years_birthday=Date Then
message="Happy birthday!!"
Else
message=days_to_birthday &" days to go!"
End If

'output information

msg="This is your birthday analysis:" & vbCr
msg=msg+"You are born on "& birthday & vbCr
msg=msg+"You are " & age_in_years &" yrs old. That's" & vbCr
msg=msg &age_in_months &" months or " & age_in_days &" days!" &vbCr
msg=msg+"You were born on a " & day_born &vbCr
msg=msg+"This year's birthday is on " & this_years_birthday &vbCr
msg=msg+"It's a " &day_celebrating &vbCr
msg=msg+message

MsgBox msg

' Use the method of superimposing msg itself to achieve the final input effect, which is very typical, and you should master it.
```

[ Last edited by Billunique on 2007-6-14 at 11:12 AM ]
★①②③④⑤⑥⑦⑧⑨⑩㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ【●】→←↑↓▲
Floor 43 Posted 2007-06-06 10:45 ·  中国 北京 雅虎中国
中级用户
★★
菜鸟总动员
Credits 259
Posts 112
Joined 2006-08-28 15:53
19-year member
UID 61454
Status Offline
Just Need to Confirm the Opinion

  In many cases, you don’t need text input. You just need a simple Yes-or-No decision. VBScript contains a very versatile tool that allows you to ask all kinds of simple questions. It’s called MsgBox—you’ve already used this function to display plain text information.

  You can call a function using parentheses, and it will return a value. If you call a function as a procedure, without using parentheses, it will not return a value. MsgBox is a function. When you use it as a procedure, it will simply output information. If you want to base decisions on MsgBox dialog boxes, then use it as a function, and check which value MsgBox returned.

  The easiest way to call MsgBox as a function looks like this:
result = MsgBox(“Do you agree?”)


  The parameters after MsgBox, the first is the content, the second is the display buttons + tone flags + default selected button, the third is the title; the following are for help, basically not used.

  

  For example, we can use it like this:
result = MsgBox(“Continue?”, vbYesNo+vbQuestion, “What now?”)


  The return value can be referred to in the following figure:
  

[ Last edited by Billunique on 2007-6-6 at 11:21 AM ]
★①②③④⑤⑥⑦⑧⑨⑩㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ【●】→←↑↓▲
Floor 44 Posted 2007-06-06 11:45 ·  中国 北京 雅虎中国
中级用户
★★
菜鸟总动员
Credits 259
Posts 112
Joined 2006-08-28 15:53
19-year member
UID 61454
Status Offline
'get arguments as collection object
set args = WScript.Arguments
' check whether there are any arguments:
if args.Count = 0 then
'no arguments
MsgBox “You called this script directly, no arguments specified!”
else
for each argument in args
list = list & argument & vbCr
next
MsgBox “Here’s the list of arguments:” & vbCr & list
end if


  Using the above code, you can create a "argument reader" that also supports argument dragging. Once dragged in, the information of the arguments will be clear at a glance.

  This involves the usage of set, the usage of for each...next, the Count method of the Arguments object; and the most typical and worthy of reference is the usage of that list. By using the loop and the method of superimposing the list itself, a good output effect is achieved, which should be mastered.
★①②③④⑤⑥⑦⑧⑨⑩㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ【●】→←↑↓▲
Floor 45 Posted 2007-06-13 19:24 ·  中国 北京 雅虎中国
中级用户
★★
菜鸟总动员
Credits 259
Posts 112
Joined 2006-08-28 15:53
19-year member
UID 61454
Status Offline
The following code can be used to write a very good small VBS debugger; details don't need to be cared about for the time being, just record it for now.

'Check whether the script is run in CScript (DOS environment)
host = WScript.FullName
hostexe = LCase(Mid(host, InStrRev(host, "\") + 1))
If Not hostexe = "cscript.exe" Then
'Error! We are running in wscript. So let's re-launch in cscript!
Set wshshell = CreateObject("wscript.shell")
wshshell.Run "cscript.exe""" & WScript.ScriptFullName & """"
'Quit
WScript.Quit
End If

'Get access to input and output stream:
Set input = WScript.StdIn
Set output = WScript.StdOut

output.Write "> "
Do Until input.AtEndOfStream
'Read in lines:
line = input.ReadLine
'Exit condition: stop the loop once someone enters "exit"
If LCase(line) = "exit" Then
Exit Do
Else
'Interpret the command:
'Replace? with output command
line = Replace(line, "?", "output.writeline")
executeit line
output.Write "> "
End If
Loop

Sub executeit(command)
'Execute is a separate procedure because it turns off
'Built-in error handling
'This is necessary to keep the script running even if
'Invalid commands are entered:
On Error Resume Next
'Execute the statement:
ExecuteGlobal command
'Did an error occur?
If Not Err.Number = 0 Then
'Yes, report the cause:
output.WriteLine "error: " & Err.Description
Err.Clear
End If
End sub


[ Last edited by Billunique on 2007-6-14 at 10:50 AM ]
★①②③④⑤⑥⑦⑧⑨⑩㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ【●】→←↑↓▲
Forum Jump: