Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

ИВб-14-2 Информатика для ИВб

.pdf
Скачиваний:
11
Добавлен:
13.04.2015
Размер:
389.61 Кб
Скачать

MULTILEVEL DIRECTORIES

When there is more than one user on your computer, or when you are working on several different projects, the number of files in the directory can become large and unwieldy. To deal with this large number of files, you may want to keep your files separate from a coworker's or organize your programs into convenient categories.

In an office, you can separate and organize files that belong to different people or that relate to specific projects by putting them in different file cabinets. For example, you might put your accounting programs in one file cabinet and your letters in another. You can do the same thing with MS-DOS by putting your files into different directories.

Directories let you group your files in convenient categories. These directories, in turn, may contain other directories (referred to as subdirectories). This organized file structure is called a multilevel directory system.

Note: The maximum number of files or directories that the root directory may contain varies, depending on the type of disk and disk you are using. Usually the maximum number is 112 for a double-sided, doubledensity, 5.25-inch floppy disk. The maximum number of entries in the root directory of a 1.44 megabyte 3.5-inch floppy disk is 224. This maximum capacity for a root directory may vary depending upon how the disk is formatted. The number of subdirectories on a disk is not restricted.

The first level in a multilevel directory is the root directory, which is created automatically when you format a disk and start putting files on it. Within root directory, you can create additional directories and subdirectories.

As you create new directories for groups of files, or for other people using the computer, the directory system grows. And within each new directory you can add new files or create new subdirectories.

You can move around in the multilevel system by staring at the root and "traveling" through intermediate subdirectories to find a specific file. Conversely, you can start anywhere within the file system and travel toward the root. Or you can go directly to any directory without traveling through intermediate levels.

The directory that you are in is called the working directory. The filenames and commands discussed in this chapter relate to your working directory and do not apply to any other directories in the structure. When you start your computer, you start out in the working directory. Similarly, when you create a file, you create it in the working directory.

43

UNIT 9

1.Запомните следующие слова и письменно переведите тексты.

1.active scripting – активное скриптование;

2.application – приложение;

3.binary – бинарный, двоичный;

4.browser – браузер;

5.client scripting – клиентское скриптование;

6.to compile – компилировать;

7.the developer – разработчик;

8.entry points – точки входа;

9.license – лицензия, лицензировать;

10.namespace – именное пространство;

11.newest member – новейший элемент;

12.to provide – обеспечивать;

13.programming languages – языки программирования;

14.run-timeвремя выполнения (прогона);

15.script – скрипт, код;

16.server scripting – серверное скриптование;

17.support – поддержка;

18.vendors – поставщики;

19.the Visual Basic family – семейство Visual Basic;

20.Web pages – Веб-страницы.

What Is VBScript?

Microsoft Visual Basic Scripting Edition, the newest member of the Visual Basic family of programming languages, brings active scripting to a wide variety of environments, including Web client scripting in Microsoft Internet Explorer and Web server scripting in Microsoft Internet Information Server.

Easy to Use and Learn

If you already know Visual Basic or Visual Basic for Applications, VBScript will be very familiar. Even if you don't know Visual Basic, once you learn VBScript, you're on your way to programming with the whole family of Visual Basic languages. Although you can learn about VBScript in just these few Web pages, they don't teach you how to program. To get started programming, take a look at Step by Step books available from Microsoft Press.

ActiveX Scripting

VBScript talks to host applications using ActiveX® Scripting. With ActiveX Scripting, browsers and other host applications don't require special integration code for each scripting component. ActiveX Scripting enables a host to compile scripts, obtain and call entry points, and manage the namespace available to the developer. With ActiveX Scripting, language vendors can create standard language run times for scripting. Microsoft will provide runtime support for VBScript. Microsoft is working with various Internet groups to define the ActiveX Scripting standard so that scripting engines can be interchangeable. ActiveX Scripting is used in Microsoft® Internet Explorer and in Microsoft® Internet Information Server.

44

2.Запомните следующие слова и письменно переведите тексты.

1.Boolean values – логические значения;

2.classifications – классификации;

3.to convert – преобразовывать;

4.conversion functions – конверсионные функции

5.to contain – содержать;

6.data types – типы данных;

7.different kinds of information – различные виды информации;

8.distinctions – различия;

9.to enclose – заключать;

10.to express – выражать;

11.floating–point numbers – числа с плавающей точкой;

12.functions – функции;

13.integer – целое;

14.numeric – числовой;

15.quotation marks – кавычки;

16.to represent – представлять;

17.to return – возвращать;

18.string – строка;

19.subtypes – подтипы;

20.true, false – истина, ложь.

VBScript Data Types

What Are VBScript Data Types?

VBScript has only one data type called a Variant. A Variant is a special kind of data type that can contain different kinds of information, depending on how it's used. Because Variant is the only data type in VBScript, it's also the data type returned by all functions in VBScript.

At its simplest, a Variant can contain either numeric or string information. A Variant behaves as a number when you use it in a numeric context and as a string when you use it in a string context. That is, if you're working with data that looks like numbers, VBScript assumes that it is numbers and does the thing that is most appropriate for numbers. Similarly, if you're working with data that can only be string data, VBScript treats it as string data. Of course, you can always make numbers behave as strings by enclosing them in quotation marks (" ").

Variant Subtypes

Beyond the simple numeric or string classifications, a Variant can make further distinctions about the specific nature of numeric information. For example, you can have numeric information that represents a date or a time. When used with other date or time data, the result is always expressed as a date or a time. Of course, you can also have a rich variety of numeric information ranging in size from Boolean values to huge floating-point numbers. These different categories of information that can be contained in a Variant are called subtypes. Most of the time, you can just put the kind of data you want in a Variant, and the Variant behaves in a way that is most appropriate for the data it contains.

45

3.Запомните следующие слова и письменно переведите тексты.

1.an alphabetic character – алфавитный символ;

2.array variables – массивные переменные;

3.to assign – назначить, присвоить;

4.a comma – запятая;

5.declaring variables – объявленные переменные;

6.to destroy – уничтожать;

7.to determine – определять;

8.dynamic array – динамический массив;

9.embedded period – пробел;

10.explicitly – явно;

11.lifetime – жизненный цикл;

12.local scope – локальная область;

13.misspell – орфографическая ошибка;

14.multiple – многочисленный;

15.naming restrictions – ограничения присваивания имени;

16.parentheses – круглые скобки;

17.placeholder – метка-заполнитель;

18.procedure-levelпроцедурный уровень;

19.recognizable - опознавание, распознавание;

20.to retrieve – извлекать;

21.scalar variables – скалярные переменные;

22.scope – область;

23.script-levelскриптовый уровень;

24.to separate – разделять, отделять;

25.single-dimensionодномерный массив;

26.statement – утверждение;

27.two-dimensionдвумерный массив;

28.unique – уникальный;

29.value – значение;

30.variable – переменная.

VBScript Variables

What Is a Variable?

A variable is a convenient placeholder that refers to a computer memory location where you can store program information that may change during the time your script is running. For example, you might create a variable called ClickCount to store the number of times a user clicks an object on a particular Web page. Where the variable is stored in computer memory is unimportant. What's important is that you only have to refer to a variable by name to see its value or to change its value. In VBScript, variables are always of one fundamental data type, Variant.

Declaring Variables

You declare variables explicitly in your script using the Dim statement, the Public statement, and the Private statement. For example:

Dim DegreesFahrenheit

You declare multiple variables by separating each variable name with a comma. For example:

Dim Top, Bottom, Left, Right

46

You can also declare a variable implicitly by simply using its name in your script. That's not generally a good practice because you could misspell the variable name in one or more places, causing unexpected results when your script is run. For that reason, the Option Explicit statement is available to require explicit declaration of all variables. The Option Explicit statement should be the first statement in your script.

Naming Restrictions

Variable names follow the standard rules for naming anything in VBScript. A variable name:

Must begin with an alphabetic character.

Cannot contain an embedded period.

Must not exceed 255 characters.

Must be unique in the scope in which it is declared.

Scope and Lifetime of Variables

A variable's scope is determined by where you declare it. When you declare a variable within a procedure, only code within that procedure can access or change the value of that variable. It has local scope and is called a procedure-level variable. If you declare a variable outside a procedure, you make it recognizable to all the procedures in your script. This is a script-level variable, and it has script-level scope.

How long a variable exists is its lifetime. The lifetime of a script-level variable extends from the time it's declared until the time the script is finished running. At procedure level, a variable exists only as long as you are in the procedure. When the procedure exits, the variable is destroyed. Local variables are ideal as temporary storage space when a procedure is executing. You can have local variables of the same name in several different procedures because each is recognized only by the procedure in which it is declared.

Assigning Values to Variables

Values are assigned to variables creating an expression as follows: the variable is on the left side of the expression and the value you want to assign to the variable is on the right. For example:

B = 200

Scalar Variables and Array Variables

Much of the time, you just want to assign a single value to a variable you've declared. A variable containing a single value is a scalar variable. Other times, it's convenient to assign more than one related value to a single variable. Then you can create a variable that can contain a series of values. This is called an array variable. Array variables and scalar variables are declared in the same way, except that the declaration of an array variable uses parentheses ( ) following the variable name. In the following example, a single-dimension array containing 11 elements is declared:

Dim A(10)

Although the number shown in the parentheses is 10, all arrays in VBScript are zero-based, so this array actually contains 11 elements. In a zero-based array, the number of array elements is always the number shown in parentheses plus one. This kind of array is called a fixed-size array.

47

You assign data to each of the elements of the array using an index into the array. Beginning at zero and ending at 10, data can be assigned to the elements of an array as follows:

A(0) = 256

A(1) = 324

A(2) = 100

. . .

A(10) = 55

Similarly, the data can be retrieved from any element using an index into the particular array element you want. For example:

. . .

SomeVariable = A(8)

. . .

Arrays aren't limited to a single dimension. You can have as many as 60 dimensions, although most people can't comprehend more than three or four dimensions. Multiple dimensions are declared by separating an array's size numbers in the parentheses with commas. In the following example, the MyTable variable is a two-dimensional array consisting of 6 rows and 11 columns:

Dim MyTable(5, 10)

In a two-dimensional array, the first number is always the number of rows; the second number is the number of columns.

You can also declare an array whose size changes during the time your script is running. This is called a dynamic array. The array is initially declared within a procedure using either the Dim statement or using the ReDim statement. However, for a dynamic array, no size or number of dimensions is placed inside the parentheses. For example:

Dim MyArray() ReDim AnotherArray()

To use a dynamic array, you must subsequently use ReDim to determine the number of dimensions and the size of each dmension. In the following example, ReDim sets the initial size of the dynamic array to 25. A subsequent ReDim statement resizes the array to 30, but uses the Preserve keyword to preserve the contents of the array as the resizing takes place.

ReDim MyArray(25)

. . .

ReDim Preserve MyArray(30)

There is no limit to the number of times you can resize a dynamic array, but you should know that you make an array if smaller than it was, you lose the data in the eliminated elements.

4.Запомните следующие слова и письменно переведите тексты.

1.capital letters – основные буквы;

2.confusion – неразбериха;

3.constant – константа, постоянная;

4.complex script – сложный скрипт;

5.date literals – литералы даты;

6.differentiating – различие;

7.to define – определять;

8.to eliminate – устранять;

9.intrinsic constants – существенные константы;

10.literal values – буквенные значения;

11.meaningful – значимый;

12.never changes – никогда не изменяется;

13.prefix – префикс, приставка;

14.to reassign – переназначать;

15.sign – знак.

48

VBScript Constants

What Is a Constant?

A constant is a meaningful name that takes the place of a number or string and never changes. VBScript defines a number of intrinsic constants. You can get information about these intrinsic constants from the VBScript Language Reference.

Creating Constants

You create user-defined constants in VBScript using the Const statement. Using the Const statement, you can create string or numeric constants with meaningful names and assign them literal values. For example:

Const MyString = "This is my string." Const MyAge = 49

Note that the string literal is enclosed in quotation marks (" "). Quotation values. Date literals and time literals are represented by enclosing them in number signs (#). For example:

Const CutoffDate = #6-1-97#

You may want to adopt a naming scheme to differentiate constants from variables. This will prevent you from trying to reassign constant values while your script is running. For example, you might want to use a "vb" or "con" prefix on your constant names, or you might name your constants in all capital letters. Differentiating constants from variables eliminates confusion as you develop more complex scripts.

5.Запомните следующие слова и письменно переведите тексты.

1.arithmetic operators – арифметические операторы;

2.comparison operators – операторы сравнения;

3.concatenation operators – операторы конкатенации;

4.division – деление;

5.equal precedence – равный приоритет;

6.to evaluate – оценивать;

7.an expression – выражение;

8.in the left-to-right – слева направо;

9.logical operators – логические операторы;

10.multiplication – умножение;

11.operator – оператор;

12.operator precedence – оператор приоритета, первоочередности;

13.to override – аннулировать;

14.a predetermined order – предопределенный порядок;

15.the string concatenation operator – оператор строковой связи.

VBScript Operators

VBScript has a full range of operators, including arithmetic operators, comparison operators, concatenation operators, and logical operators.

Operator Precedence

When several operations occur in an expression, each part is evaluated and resolved in a predetermined order called operator precedence. You can use parentheses to override the order of precedence and force some parts of an expression to be evaluated before others. Operations within parentheses are always performed before those outside. Within parentheses, however, standard operator precedence is maintained.

49

When expressions contain operators from more than one category, arithmetic operators are evaluated first, comparison operators are evaluated next, and logical operators are evaluated last. Comparison operators all have equal precedence; that is, they are evaluated in the left- to-right order in which they appear. Arithmetic and logical operators are evaluated in the following order of precedence.

Arithmetic

 

Comparison

 

Logical

 

 

 

 

 

 

 

Description

Symbol

Description

Symbol

Description

Symbol

 

 

 

 

 

 

Exponentiation

^

Equality

=

Logical negation

Not

 

 

 

 

 

 

Unary negation

-

Inequality

<>

Logical conjunction

And

 

 

 

 

 

 

Multiplication

*

Less than

<

Logical disjunction

Or

 

 

 

 

 

 

Division

/

Greater than

>

Logical exclusion

Xor

 

 

 

 

 

 

Integer division

\

Less than or equal to

<=

Logical equivalence

Eqv

 

 

 

 

 

 

Modulus arithmetic

Mod

Greater than or equal to

>=

Logical implication

Imp

 

 

 

 

 

 

Addition

+

Object equivalence

Is

 

 

 

 

 

 

 

 

Subtraction

-

 

 

 

 

 

 

 

 

 

 

String concatenation

&

 

 

 

 

 

 

 

 

 

 

When multiplication and division occur together in an expression, each operation is evaluated as it occurs from left to right. Likewise, when addition and subtraction occur together in an expression, each operation is evaluated in order of appearance from left to right.

The string concatenation (&) operator is not an arithmetic operator, but in precedence it does fall after all arithmetic operators and before all comparison operators. The Is operator is an object reference comparison operator. It does not compare objects or their values; it checks only to determine if two object references refer to the same object.

50

Digital Computers

There are two fundamentally different types of computers: analog and digital. In current usage "computer" usually refers to high speed digital computers. These computers are playing an increasing role in all branches of the economy. Digital computers are based on manipulating discrete binary digits ( I s and Os). They are generally more effective than analog computers for four principal reasons: they are faster: they are not so susceptible to signal interference; they can transfer huge data bases more accurately; and their coded binary data are easier to store and retrieve than the analog signals. For all their apparent complexity, digital computers are considered lo be simple machines. Digital computers are able lo recognize only two states in each of its millions of switches, "on" or "off", or high voltage or low voltage. By assigning binary numbers to these states 1 for "on" and 0 for "off", and linking many switches together, a computer can represent any type of data from numbers lo letters and musical notes. It is this process of recognizing signals that is known as digitization. The real power of a computer depends on the speed with which it checks switches per second. The more switches a computer checks in each cycle, the more data it can recognize at one time and the faster it can operate, each switch being called a binary digit or bit. A digital computer is a complex system of four functionally different elements: 1) the central processing unit (CPU). 2) input devices. 3) memory-storage devices called disk drives, 4) output devices. These physical parts and all their physical components are called hardware.

The central processing unit is the heart of a computer. In addition to performing arithmetic and logic operations on data, it controls the rest of the system. Sometimes the CPU consists of several linked microchips, each performing a separate task, but most computers require only a single microchip as the CPU.

Input devices let users enter commands, data, or programs for processing by the CPU. Information typed at the computer keyboard, which is much like typewriter, is translated into a series of binary numbers the CPU can manipulate. The mouse is another widely used mechanical input device to move the cursor on the display screen, the user moves the mouse, selects operations and activates commands on the screen by pressing buttons on the top of the mouse. The power of computers greatly depends on the characteristics of memory-storage devices.

Most digital computers store data both internally in what is called mam memory, and externally, on auxiliary storage units. As a computer processes data and instructions, it temporary stores information internally on special memory microchips. Auxiliary storage units supplement the main memory when programmes are too large and they also offer a more reliable method for storing data. There exist different kinds of auxiliary storage devices removable magnetic disks being the most widely used. They can store up to 100 megabytes of data on one disk, a byte being known as the basic unit of data storage.

Output devices let the user see the results of the computer's data processing. Being the most commonly used output device, the monitor accepts video signals from a computer and shows different kinds of information such as texts, formulas and graphics on its screen. With the help of various printers information stored in one of the computer's memory systems can be easily printed on paper in a desired number of copies.

Programmes, also called software, are detailed sequences of instructions that direct the computer hardware to perform useful operations. Due to a computer's operating system hardware and software systems can work simultaneously. An operating system consists of a number of programmes coordinating operations, translating the data from different input and output devices, regulating data storage in memory, transferring tasks to different processors and functions that help programmers to write software. In large corporations software is often written by groups of experienced programmers each person focusing on a specific aspect of the total project. For this reason scientific and industrial software sometimes costs much more than the computers on which the programmes run.

51

Error Messages by Numbers

1. File does not exist

3.File is in use

4.End of file encountered

5.Record is out of range

6.Too many files open

7.File already exists

9.Data type mismatch

10.Syntax error

11.Function argument value, type, or count is invalid-

12.Variable "variable" is not found

13.Alias is not found

16.Unrecognized command verb

17.Table number is invalid

18.Line is too long

19.Index file does not match table

20.Record is not in index

21.Length of variable strings exceeds amount of memory-

22.Too many variables

23.Index expression exceeds maximum length

24.Alias name is already in use

26.Table has no index order set-

27.Not a numeric expression

30.Row or column position is off the screen

31.Invalid subscript reference

34. Operation is invalid for a Memo, General, or Picture field

36.Command contains unrecognized phrase/keyword

37.You must use a logical expression with FILTER-

38.Beginning of file encountered

39.Numeric overflow. Data was lost

41.Memo file "name" is missing or is invalid

42.The LOCATE command must be issued before the CONTINUE command-

43.There is not enough memory to complete this operation

45.Not a character expression-

46.Expression evaluated to an illegal value

47.No fields found to process

50. Report file "name" is invalid

52. No table is open in the current work area

54.Label file is invalid

55.Memory file is invalid

56.There is not enough disk space for "name

62.Cannot access characters beyond string

67. Expression evaluator failed

91. File was not placed in memory using the LOAD command

94.Must specify additional parameters

95.Statement is not allowed in interactive mode

52