• No se han encontrado resultados

Freirean approaches to empathy in critical pedagogy theory

CHAPTER 2: EMPATHY IN CRITICAL PEDAGOGIC PRACTICE

2.3 Empathy in critical pedagogy of higher education

2.3.1 Freirean approaches to empathy in critical pedagogy theory

1.17. Built-in procedures. Usage of standard windows

Visual Basic includes a considerable quantity of the built-in procedures, which differ from the user-defined procedures in the following: developers of the Visual Basic features programmed their declarations. These declarations are hid-den from us as the program developer.

The built-in procedures, as well as the user-defined procedures, are divided into functions and subroutines.

We have already encountered the built-in functions of VB. They are:

functions reviewed in Section 1.9;

IIf in Section 1.12;

IsMissing in Section 1.16, etc.

Below is considered built-in function InputBox intended for input of in-formation (into the program) by means of the standard windows of operating system Windows.

An example of the built-in subroutine is the MsgBox procedure intended for output of information (from the program) into the standard windows.

We will use InputBox and MsgBox in the program from Section 1.1, in-tended for calculating the hypotenuse length, with which we began studying VB.

1. Let us enter the following program into the code window:

Listing 1.3 Sub Pythagoras1()

Dim a As Single Dim b As Single Dim c As Single Dim s As String 1: s = InputBox( _

"Enter length of the first leg and click OK") 2: a = Val(s)

3: s = InputBox( _

"Enter length of the second leg and click OK") 4: b = Val(s)

5: c = Sqr(a ^ 2 + b ^ 2) 'according to Pythagoras 6: s = Str(c)

7: MsgBox s End Sub

2. Let us run the Pythagoras1 program. The window appears (Fig. 1.12), offering to input the length of the first leg of a right-angled triangle. Let us put, for example, 400 (without inverted commas) into the text box of this window by means of the keyboard and click on the OK button.

Fig. 1.12. The first window (on the Excel worksheet) for inputting the source data

3. The window appears (Fig. 1.13), offering to input the length of the second leg. Let us put, for example, 300 and click on OK.

Fig. 1.13. The second window for inputting the source data

4. The window appears (Fig. 1.14), containing the hypotenuse length calcu-lated. Let us click on the OK button to close this window and terminate the pro-gram execution.

1.17. Built-in procedures. Usage of standard windows

Fig. 1.14. The window with the result

In the above program, operator 1 includes the InputBox function call, which is used for entering information from the keyboard. This function returns the string, which was entered into the text box of the window in Fig. 1.12, i.e.,

"400". This string is assigned to the s variable of the String data type.

Operator 2 converts the s string’s value to number 400 and assigns this number to the a variable of the Single data type.

Operator 3 assigns string "300", which was entered into the text box of the window in Fig. 1.13, to the s variable. Operator 4 converts the s string’s value to number 300 and assigns this number to the b variable.

Operator 5 calculates the hypotenuse length according to the Pythagoras the-orem. The calculated value of 500 is assigned to variable c. Operator 6 converts 500 to string; as a result, the s string’s value becomes "500".

Operator 7, which is the call of the built-in MsgBox subroutine, opens the window with value 500 calculated (Fig. 1.14). As in the case of the user-defined subroutine, operator 7 may be written in the following form:

Call MsgBox(s)

The calls of built-in procedures InputBox and MsgBox have only one parameter (of the String data type), which is obligatory. However, these pro-cedures also have optional parameters, whose appointment may be looked in the Excel help system started by pressing the F1 key when the VB window is active.

Before pressing this key, we recommend to locate the blinking cursor on the required word (InputBox or MsgBox) in the code window containing program Pythagoras1.

In the Excel help system, the MsgBox procedure is termed as a function, instead of a subroutine, because the call of MsgBox may be a part of arithmetic

expressions. In this case, MsgBox returns (into the program) the integer value depending on the button, on which the user clicked. In the example below, we will consider using the MsgBox procedure as a function.

For calculating the area of a right-angled triangle by the Pythagoras1 program, we replace operator 7 by three operators labeled by 7, 8 and 9. The following program is the result:

Sub Pythagoras2() Dim a As Single Dim b As Single Dim c As Single Dim s As String 1: s = InputBox( _

"Enter length of the first leg and click OK") 2: a = Val(s)

3: s = InputBox( _

"Enter length of the second leg and click OK") 4: b = Val(s)

5: c = Sqr(a ^ 2 + b ^ 2) 'according to Pythagoras 6: s = Str(c)

7: Dim Ret As Integer

8: Ret = MsgBox(s, vbYesNo, _

"Do you want to calculate area?") 9: If Ret = vbYes Then MsgBox Str(a * b / 2) End Sub

In operator 8, procedure MsgBox is a function. In this case, the procedure parameters are in parentheses.

When executing the Pythagoras2 program, the window with the hypote-nuse length calculated has other content (Fig. 1.15). After clicking on the Yes button, the window with the triangle area calculated is displayed (Fig. 1.16).

By clicking on the OK button, we terminate the program execution.

Operators 7 — 9 of the last program may be replaced by operator If MsgBox(s, vbYesNo, _

"Do you want to calculate area?") = vbYes _ Then MsgBox Str(a * b / 2)

This also gives the results shown in Fig. 1.15 and 1.16.

1.17. Built-in procedures. Usage of standard windows

Fig. 1.15. The first resulting window

Fig. 1.16. The second resulting window

1.18. Records

A record or user-defined data type is a collection of variables, possibly of dif-ferent data types, grouped together under a single name for convenient handling.

Each variable of the record is called a field.

Before usage of a record, we must create it by means of the Type operator with the following syntax:

Type struct

field1 As type1 field2 As type2 ∙ ∙ ∙ ∙ ∙ fieldN As typeN End Type

where struct is a name of the record, field1, field2, …, fieldN are the field names, type1, type2, …, typeN are data types (Appendix 1) for the corresponding fields.

The record creation operator must be placed in the general declarations area of the program, which uses this record.

For example, we have to work up results of a university session, where the following three subjects were evaluated: physics, mathematics and informatics.

In this case, the following fields are necessary:

1) name of the student;

2) number of the test book;

3) mark in physics;

4) mark in mathematics;

5) mark in informatics.

Let the name of the record be Session, and let the field names be Name, Number, Physics, Math and Inform. In this case, the record creation opera-tor has the following form:

Type Session

Name As String Number As Long

1.18. Records Physics As Byte

Math As Byte Inform As Byte End Type

To get access to the created record (by name struct), we have to declare one or several variables in the program by means of the Dim operator, in the same way as we declared variables in Section 1.3.

The declaration operator has the following syntax:

Dim variable As struct

where variable is the variable name, struct is the variable’s data type.

For example, operator

Dim Sess As Session, BestSess As Session

declares variables (records) Sess and BestSess of the Session data type.

For the reference to the record field, we use the variable and field names separated by a point.

For example, assignment operator Sess.Name = "Maksim Zakharkin"

contains the reference in the left-hand side. As a result of the operator execution, string

"Maksim Zakharkin"

is assigned to the Name field of the Sess variable (of type Session).

For filling the fields, it is convenient to use the With operator, which has the following syntax:

With variable

.field1 = expression1 .field2 = expression2 ∙ ∙ ∙ ∙ ∙ ∙ ∙ .fieldN = expressionN End With

In this operator, expression1, expression2, ..., expressionN are arithmetic or logical expressions (Sections 1.8 and 1.10) or strings, which can be considered as expressions (Section 1.19).

For example:

With Sess

.Name = "Maksim Zakharkin"

.Number = 02237 .Physics = 4 .Math = 5 .Inform = 5 End With

The assignment operator can be applied both to fields and to entire records, as in the following examples:

BestSess.Number = Sess.Number BestSess = Sess

Arrays of records may be used. For example, it is natural to store the marks obtained by students of group E13 in array SessE13. If this array of records is static, it is declared as follows:

Dim SessE13(1 To 15) As Session

For example, let us consider the following code for calculating distance between Tushino and Ostankino on the Moscow map.

Listing 1.4 Type Point

Name As String x As Single y As Single End Type

Sub TushinoOstankino() Dim P() As Point ReDim P(0 To 1) With P(0)

.Name = "Tushino"

.x = 17.6 .y = 29.7 End With

1.18. Records With P(1)

.Name = "Ostankino"

.x = 44.1 .y = 37.5 End With

MsgBox Str(Distance(P())) 'output of 27.62408 End Sub

Function Distance(positions() As Point) As Single Distance = _

Sqr((positions(0).x - positions(1).x) ^ 2 + _ (positions(0).y - positions(1).y) ^ 2)

End Function

Code Listing 1.4 includes the operator creating the Point record, program TushinoOstankino and the Distance function. This code has the follow-ing peculiarities:

P is the dynamic array of records of the Point data type;

the Distance function argument is the array of records of type Point.

To understand the work of program TushinoOstankino, we advise the reader to execute it step-by-step, watching the P array in window Watches.

Before the first press of the F8 key, the blinking cursor should be located in the TushinoOstankino program, not in the operator creating the Point record and not in the Distance function.