Файл: ИВб-14-2 Информатика для ИВб.pdf

ВУЗ: Не указан

Категория: Не указан

Дисциплина: Не указана

Добавлен: 30.03.2024

Просмотров: 172

Скачиваний: 0

ВНИМАНИЕ! Если данный файл нарушает Ваши авторские права, то обязательно сообщите нам.

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