Programming Taskbook


E-mail:

Password:

User registration   Restore password

Russian

SFedU

1100 training tasks on programming

©  M. E. Abramyan (Southern Federal University), 1998–2018

 

Examples | Visual Basic | PT4 procedures

PrevNext


Additional procedures

Procedures described below will be available in a program if PT4Main module is added to the program (any template project created for task solving on Visual Basic contains this module).

Task initialization, data input-output


Public Sub Task(ByVal Name As String)

This procedure initializes a task named Name. It must be called at the beginning of the Solve procedure that contains task solution. If the Solve procedure does not contain the Task procedure call then the program output the error message "The Task procedure with a task name is not called".

A task name must contain a name of a task group and an order number (for example, "Begin3"). If the group name is invalid then the program output the error message "Invalid task group". If the task number is invalid then the program output the error message with information about the range of the available task numbers for this group. The symbol "?" placed after the task name (for example, "Begin3?") means that the program will be run in the demo mode.

Starting from the version 4.8, the Task procedure may be also used for creating and displaying an html-page containing a description of a task or a task group. In this case the name of the required task or the task group ended by the "#" symbol must be used for the Name parameter, for example, "Begin3#" or "Begin#".

Starting from the version 4.13, the Programming Taskbook provides a program testing on several sets of input data during a single running of the program. You should place the sumbol "!" after the task name (for example, "Begin3!") in order to switch off this new feature.

All subsequent calls of the Task procedure are ignored with the following exception: if several calls are used for creation of an html-page containing a description of various tasks or task groups then all these calls will be taken into account.

Starting from the version 4.12, the Name parameter may include the "_en" or "_ru" suffix that determines the interface language (English or Russian respectively) for Programming Taskbook window and the task itself. The "?", "#", and "!" symbols should be placed before the suffix, for example, "Begin3#_en". If several calls of the Task procedure are used (for creation of an html-page) then only the suffix of the first call will be taken into account. If the suffix is absent then the default language is applied (the default language may be changed by means of a pop-up menu of the PT4Load tool).


Public Sub GetB(ByRef A As Boolean) Public Sub GetN(ByRef A As Integer) Public Sub GetD(ByRef A As Double) Public Sub GetS(ByRef A As String)

These procedures must be used to input initial data values in the program. They must be called after the Task procedure, otherwise the program output the error message "The Task procedure with a task name is not called at the beginning of the program".

Each input procedure must correspond to the type of data item, otherwise the program output the following message: "Invalid type is used for an input data item" . For example, this message will be output if GetN procedure will be called for input a string.

The GetS procedure must be used for both string and character input, because Visual Basic has no special type for characters.

In the case of input of more data than the task requires, the program output the error message "An attempt to input superfluous data". In the case of input of less data than the task requires, the program output the error message "Some required data are not input".


Public Sub PutB(ByVal A As Boolean) Public Sub PutN(ByVal A As Integer) Public Sub PutD(ByVal A As Double) Public Sub PutS(ByVal A As String)

These procedures must be used to output results on the screen and compare obtained results with control data (i.e., correct results). They must be called after the Task procedure, otherwise the program output the error message "The Task procedure with a task name is not called at the beginning of the program".

Unlike the Get-procedures, parameters of the Put-procedures can be expressions (in particular, constants of a corresponding type). The used procedure should correspond to output data item, otherwise the program output the error message "Invalid type is used for an output data item".

The PutS procedure must be used for both string and character output.

In the case of output of more data than the task requires, the program output the error message "An attempt to output superfluous data". In the case of output of less data than the task requires, the program output the error message "Some data are not output".

Output debug info

Procedures described below are intended to output some debug data into the debug panel located below the task panels of the Programming Taskbook window.


Public Sub Show(ByVal S As String)

Shows a text string S in the debug panel. The string S may contain explicit line-breaks as follows: Chr(13) (carriage return), Chr(10) (new line) or their combination Chr(13) & Chr(10).

You may use numeric data as a parameter of the Show procedure. In this case a number will be converted automatically to its string representation. You may also output numeric data jointly with the preceding comment using the & operator, for example:

[VB5-6]

Show "A = " & A

[VB.NET]

Show("A = " & A)

Here A is a numeric variable (of the type Integer or Double).


Public Sub ShowLine(ByVal S As String)

The ShowLine procedure additionally breaks the current screen line.


Public Sub HideTask()

The HideTask procedure hides all sections of the Programming Taskbook window with the exception of the debug section (and therefore increases the debug panel height). If the debug panel contains no data then the call of the HideTask procedure is ignored. All subsequent calls of this procedure are ignored too.

After displaying the Programming Taskbook window you can hide/restore task sections of this window by means of the space key or the command of the pop-up menu.


PrevNext

 

  Рейтинг@Mail.ru

Designed by
M. E. Abramyan and V. N. Braguilevsky

Last revised:
06.05.2018