# It is OS/2 and is BASIC Vol 2.

(Programming by VisualAge for BASIC by the beginner)

### INDEX

It leaps to OS/2 software. It leaps to Vol1. It leaps to a homepage.

1. It is creation of GUI application, without using a sample.
   Creation of form
   A setup of property
   Programming of behavior of an object
   Point
2. Use of VisualAge familiar Q&A service
3. Chapter 4 Tutorial of SOM Object Use
   Lesson 1: The addition to the tool box of SOM Calculator
   Lesson 2: Creation of the calculator only for users, and programming of behavior
4. Creation of the application which displays the date and time

### It is creation of GUI application, without using a sample.

In the GUI application (inventory system) created previously, it created using the module by which coding was carried out beforehand, or the designed form. However, since almost all things were created if a sample is often looked at, it decided to create from the start personally for study.

It leaps to INDEX.

### 1. Creation of form

They are six pieces to the form (form for performing edit of data, an addition, deletion, save of a file, etc.) Form1 which becomes main in Lesson1.prj. There is a Command object, property is set as each, and the code of an event PUROSHI jar is also inputted. Each setup is carried out also to the form for the input screens of another data, and Form2. Although this is created from the start, what has the complicated code inputted is inputted. Pains were taken for a Sub PUROSHI jar etc. to come out and also make the copy of the same thing, although it inputted as it is, since a meaning was not understood.

A Command object is made to Form1.

1. "File" New form is opened by => "a new project."
2. The "Ctrl" key is kept pushed and it is in a tool box. A Command component is clicked.
3. The "Ctrl" key is detached. (Now, continuation addition mode began)
4. A mouse is moved to form.
5. It arranges perpendicularly the right-hand side on form, and six zones are clicked. Six Command objects are created by form. (In order to escape from continuation addition mode, the "Esc" key is pushed or a pointer icon (Pointer of an arrow) is clicked by the tool box.)

Creation of Form2

1. "File" => "new form" is chosen or the button of new form creation is clicked.
2. Two "Command components" creation and creates a "Label component" continuously in two and two "Text components" like Form1. A "Text component" is the input item of additional data, and has two, explanation of an item, and the number of an item. As for a "Label component", each explanation enters. "Command components" is an object for "preservation" of a file, and a "revocatory" button the back.

It leaps to INDEX.

### 2. A setup of property

Next, Form1 The property of the new component of Form2 is set up. Here, since it set up previously, it excludes.

It leaps to INDEX.

### 3. Programming of behavior of an object

Now, it is at it. Sample The code described by samples\tutorial\tutor1\tutor1.prj will be printed and it will describe by the code editor similarly. Since this code is also written in English as copyright is involved, although it is not understood well, either, they are carried out, it is and it has description. For the reason, since it cannot write, as [ the ] is omitted.

#### Programming of From1

1. At first, it starts with Form1. A code editor is opened.
2. "By the module" About Form1, it is in "an object/class". Click is chosen for Command1 by "the event/method."

   > Sub Command1_Click(Index As Integer)
   > Select Case Index
   > It is each here. The selection item when clicking a Command object is described.
   > End Select
   > End Sub

   It を入力.
3. "In next, an object/class" Load is chosen for Form by "the event/method."

   > Sub Form_Load()
   > It is with List1 to the beginning here. The character sequence displayed on List2 is described.
   > End Sub

   It を入力.
4. Shortly, it is at a "module". About Form1, it is in "an object/class". general is chosen. (It did not understand here easily however and was troubled)

   > Sub Add_()
   > Form2.Caption = -- "the text set to the title bar of form 2 is specified here"
   > All_Disabled
   > Form2.Show
   > End Sub

   If it inputs, it will be displayed on the place of "an event/method" as Add_. It seems that the property of Form2 is set up here.
5. Similarly, it is at a "module". About Form1, it is in "an object/class". general is chosen.

   > Sub All_Disabled()
   > Here, based on the specified ethics test, it controls whether the command of each Command object is executed. It seems [ it ] that it is making return False here, respectively.
   > End Sub

   An input displays All_Disabled on the place of "an event/method."
6. Similarly, it is at a "module". About Form1, it is in "an object/class". general is chosen.

   > Sub Delete_()
   > Here, it is If.... The Then sentence came out. A meaning is described as it is, although it does not understand.
   > End Sub

7. Similarly, it is at a "module". About Form1, it is in "an object/class". general is chosen.

   > Sub Edit_()
   > Here, it is If.... The Then sentence came out. A meaning is described as it is, although it does not understand.
   > End Sub

8. Similarly, it is at a "module". About Form1, it is in "an object/class". general is chosen.

   > Sub Exit_()
   > "Dim" which does not understand a meaning although it seems that the code for ending can be started here, and "If ... there are Then", "Message", "Answer", etc.
   > End Sub

9. Similarly, it is at a "module". About Form1, it is in "an object/class". general is chosen.

   > Sub New_()
   > It is the point also here. The code just like Sub Exit_() is written.
   > End Sub

10. Similarly, it is at a "module". About Form1, it is in "an object/class". general is chosen.

    > Sub Save_()
    > Although a meaning is not understood here, "Dim", "CMDialog1", "Print", etc. come out.
    > End Sub

11. With the above The codes of Form1 are all. It types carefully so that it may strike and there may be no between 違.

#### Programming of Form2

1. then, a code editor -- "module" Form2 -- "an object/class" -- Cancel_Item -- "an event/method" Click ... is chosen

   > Sub Cancel_Item_Click ()
   > Although it seems that various setup is carried out, it does not understand here. It writes similarly.
   > End Sub

2. module Form2 -- "an object/class" Save_Item -- "an event/method" -- Click ... is chosen"

   > Sub Save_Item_Click ()
   > Here, it is If... The Then sentence came out. Although written [ that it is various and ], since it does not understand, it writes as it is.
   > End Sub

3. By the module About Form2, it is in "an object/class". In general, "an event/method" is blank."

   > Sub All_Enabled()
   > Here, it is Form1. Based on the specified ethics test, it controls whether the command of the object of Command is executed. It seems [ it ] that it is making return True here, respectively.
   > End Sub

   After an input finishes, it is to "an event/method". It is displayed as All_Enabled.

It leaps to INDEX.

### 4. Point

Now, above, it is a sample. It is the reason which made lesson1.prj from the start. The point progresses to "creation of GUI application" of Vol1 after this. Although turn became opposite, it means making "creation of GUI application" from the beginning.
It comes out here. In Sub, it is easy and arrangement of pro SHIJA can be performed rather than it writes by the method and If...Then which call sub pro SHIJA in menu form by Form1. Me Although If....Then is not understood well, either, Sub seems to be quite important and is likely to have 使道.
When writing sub pro SHIJA, it is in "an object/class". It became study considerably to choose general and to write pro SHIJA etc. Confidence followed for a while. I think that it will make from the beginning, without also using a sample this time.
However, since the meaning of pro SHIJA is not understood, doesn't it know that whether to study from the foundation about pro SHIJA is [ the point and study ] earlier after this? It is still progressing to 52 pages "before using it." Is it at least a half?
I think that the books "a guide to IBM VisualAge for Basic" will be purchased.

Moreover, on-line information "VisualAge for Basic" holder => "VisualAgefor Basic information" The method of adding behavior to the object of VisualAgefor Basic is explained by "creation of a 第 2 part code" of => "a programming guide." Moreover, how to apply object oriented programming techniques, such as a class definition, is also explained. Since the coding method of the program for error processing is explained to the last, first of all, this is learned.

It leaps to INDEX.

### 5. Use of VisualAge Familiar Q&A Service

VisualAge Family It comes out and information is offered in forum form using the news function of the Internet. This news group is consulted very much. It becomes a secure view to a beginner. NetscapeNavigator The method of use of the newsgroup of NewsReader/2 is explained.
Here How to access a news group using NewsReader/2 was learned. Was also use of NewsReader/2 easy?
(Note) When used by Netscape Navigator, character transformation took place. Since there is also no character transformation and it was displayed when it went into the newsgroup from the homepage, the direction using NetscapeNavigator should use from the direction of a homepage.
Those who do not program also need to experience use of a newsgroup.

It leaps to INDEX.

### Chapter 4 Tutorial of SOM Object Use

In this tutorial, the creation method of the visual application which uses the mathematics function of an SOM object is learned. SOM engine -- this All codes required for execution of mathematical operation operation of the graphical user interface (GUI) to create are contained. There is a label which displays the command button arrangement which works as a key of a calculator, and a calculation result in application.

Speaking concretely, in this tutorial, learning the following items.

- How to add an SOM component to a tool box
- How to use the method defined as the SOM class as action which is behind a visual calculator

Here, since it is written by "read the chapter of integration of the SOM object of a programming guide in them if not detailed in the term and structure of SOM", advance first from the teachings that "the more haste, the less speed" by programming there.

### Programming guide Integration of the object of の SOM

By the programming guide, it is a systems object model. (SOM) The method of using a class with application is written. At this chapter, it is [ SOM and ] an SOM class. How to process by VisualAge for Basic is explained.

- Creation of an SOM IDL file.
- A setup of an SOM environment variable.
- Specification of an initialization function.
- Registration of an SOM object.
- Loading of the object to Toolbox.

1. SOM

Although it does not understand well in explanation, seemingly it is the thing of object oriented programming technology. Seemingly IDL is the standard language called interface definition language. What is written the back cannot be understood.

2. Creation of SOM IDL File

When creating an SOM IDL file, it is necessary to include a dllname='name.dll" sentence in an implementation section. For example, Calculator There is the following sentence in IDL.

> dllname = "calc.dll";

Although written, it does not understand in the least in what thing.

3. Setup of SOM Environment Variable

Although it has written that an environment variable specifies an SOM compiler, an interface RIBOJI tree framework, and information required at the time of execution, can't he understand the language which comes out? The contents currently written for a long time are also nonsense. The last direction had the following description.

Important :
  the case where he wants to use an SOM object -- a VWADDSOM environment variable -- surely -- Please set it as YES. This variable can be set as CONFIG.SYS or can be set up if needed.

I will put into the head here.

4. Specification of Initialization Function

It does not know that it is written here.
In order to support dynamic loading of the library by the SOM class manager, it is necessary to specify the initialization function of a class library.
Although it is somehow full of necessities and the example of an initialization function is written, it does not understand at all.

> void SOMLINK SOMInitModule(integer4 majorVersion, integer4 minorVersion).*minorVersion)printf("initializing\n");
> SOM_TraceLevel = 1;
> /* PrintStaticClassInfo(&SomCalculatorSCI); */ SomCalculatorNewClass(0,0);
> /* PrintStaticClassInfo(&SomCalculatorSCI); */ fflush(stdout);

5. Registration of SOM Class

Here, a SomCalculator class is registered and it is at the execution time. The method of adding to Toolbox is written.

"First, a SomCalculator object is accessed and the next file is copied to each one of directories."
Although written, it is not understood that it accesses a SomCalculator object what it carries out. Although it is written that it is [ others-] and the file of whether to attach is copied, it does not understand well too.

although "change of registered SOM DLL", "loading of SomCalculator to ToolBox", etc. are explained by this chapter, since those who do not understand although read, and are reading this homepage otherwise think that they are not interesting -- after -- excluding -- chapter 4 "before using it" The tutorial of SOM object use will be continued.

It leaps to INDEX.

### Lesson 1: The addition to the tool box of SOM Calculator

Using SOM, the work is done so that preparation may be required in it being various.

1. Setup of VWADDSOM

A user's application a VWADDSOM environment variable It turns on/turns off by whether SOM is used or not. That is, since the application (calculator) which it is going to make from now on uses SOM, is it what must set this up?

1. It is a command window. SET VWADDSOM = 1 It を入力.
2. Then, a computer is rebooted so that a new environment variable may become effective.
3. It is a value in order to set VWADDSOM as OFF. It is set as NULL. SET VWADDSOM =

(Note) NO It is Yes if it is set as 0. Seemingly, it will become the same as setting it as 1. If SOM is used frequently, it will be about SETVWADDSOM=1. Since you may not set up one by one if it describes to CONFIG.SYS, it is convenient.

2. Setup of SOMIR Environment Variable (Procedure Required for Use of SOM)

A SOMIR environment variable is updated as a procedure which accesses an interface RIPOJI tree (IR). It enables it to provide VisualAge for Basic and application with the important information about an SOM object.

1. The next is inputted in a command window. SET SOMIR= SOM.IR By this command, a user's interface RIPOJI tree is set as single FAI for [ this ] sessions.

Incidentally, when this SOM.IR file was searched, there were four as follows.

- D:\VABASIC\SOM\ETC\SOM.IR
- D:\VABASIC\SOM.IR
- D:\OS2\ETC\SOM.IR
- D:\VABASIC\takechi\tutor2\SOM.IR

3. Registration of SOM Object

An SOM object can be registered after a setup of an SOM environment variable finishes. A process called this registration can know VisualAge for Basic now about an SOM object through an SOM interface RIPOJI tree including the information about each class.
VisualAge for Basic can use an SOM object now by registration. Moreover, DLL of an SOM object must be in the place which can begin to find a loader. In short, it is that DLL is contained in the directory along which LIBPATH passes. Therefore, the following procedures are performed.

1. A directory is changed into a user's directory (d:\vabasic\takechi\tutor2) in a command window. The file of x:\VABASIC\samples\tutorial\TUTOR2 directory is copied to this directory. These files contain the module by which coding was carried out, the designed form, and an SOM class called SOMCalculator.
   [D:\]cd d:\VABASIC\takechi\tutor2
2. SOMCalculator is registered by the following command. The sc command calls an SOM compiler using the SOMCalculator class information in calc.idl. - Arrange a sir parameter so that the information that an SOM compiler is new may be put into the file of the last currently mentioned in the name in the somir environment variable. This file is SOM.IR and is set up for the preceding clause.
   [D:\vabasic\takechi\tutor2]sc -sir -u calc.idl
3. A CalculatorDLL file is put on the directory which a loader can find out.
   D: \VABASIC\takechi\tutor2\calc.dll file It copies to a d:\VABASIC\DLL directory.

4. Loading to Tool Box of SOM Object

The SomCalculator class with which registration was able to be managed is loaded to a tool box.

1. The next is inputted in a command window. VisualAge for Basic is started by this command. Now, the environment variable which the user set up becomes effective.
   [D:\VABASIC\takechi\tutor2]VW
2. From the project window of VicualAge for Basic which started, "extended function" => "SOM (OSA)" is double-clicked.
3. If "the catalog of a component" appears, "SomCalculator" will be chosen from the lists of SOM classes. The button of "SomCalculator" appears in a tool box. Then, please close "the catalog of a component."
4. "File" => "name and keep a project" is chosen in a project window, and a new project name is inputted.

It leaps to INDEX.

### Lesson 2: Creation of the calculator only for users, and programming of behavior

Now, creation of a calculator in the main question and programming of behavior are started still more.

1. Addition of Calculator Form

It is empty before adding new form. Form1 is deleted.

1. In a project window Form1 is chosen. "Finishing [ selection ]" Since the message of a check comes out by => "deletion", it deletes.
2. Next, "file" => "an addition of a file" is chosen. In a list box, D:\VABASIC\takechi\tutor2\Lesson2.i is chosen and "comprehension" is clicked.
3. Inside of a project window lesson2.i is double-clicked and form is displayed.
4. The "SOM Calculator" icon of a tool box is clicked, the pointer of a mouse is brought and dragged on the form of SOM Calculator, and a small rectangle is made. The small icon of a SOMCalculator object appears.
5. On form The small icon of a SomCalculator object is clicked and a property editor is opened. Name property It changes into myCal. please make a name this passage -- it is used when adding a code later

2. Addition of Code in Calculate() PUROSHI Jar

The Calculator PUROSHI jar which calls various mathematics methods contained in a SOM Calculator class is written.

1. (General) is chosen with an object / "class" drops down box. Calculate is chosen with an event / "method" drops down box.
2. The statement of a Calculate PUROSHI jar is inputted into Sub Calculate() of a code editor, and the place of End Sub. Although the code to input excludes, it is a fairly long code.
3. The program of a calculator will become the stage which can be tested if the above-mentioned code is inputted. Here, syntax inspection is carried out. The error did not come out.
4. Then, push an execution button in a project window and application is performed. Although application is performed, it becomes the answer which was wrong in the result of calculation. It seems that it is different in ん- - where.
5. Since the syntax which checks the Calculate PUROSHI jar also understood nothing again, current_operator of one character which is checked respectively and which was found at last was different. This is corrected and application is performed again. The calculation result also suits safely this time.

(Memorandum)

It seems that syntax inspection has a main inspection of syntax and the mistake of spelling is not found. Since the meaning of syntax is not understood, although the input of a code is inputted looking at a sample, it is serious to find it, if every character is not carefully inputted so that it may not make a mistake and an error will come out later. If the meaning of a code is understood, I will think that it is easy to find an error.
this -- a tutorial -- several times -- repeating -- carrying out -- てい -- although -- "-- a module -- " -- = -- > -- Calculator -- "-- an object -- /-- a class -- " -- = -- > -- general -- "-- an event -- /-- a method -- " -- = -- > -- declaration -- 、 -- a code -- the last -- a line -- Dim finished AS Integer -- the last -- Although there is no memory which the code here touched although the character of End Sub is added freely This was also compared with the code of a sample and has noticed the mistake. It does not understand, even if such a place error comes out.
Since he cannot fully understand about use of an SOM object, are an environmental setup to begin, the registration method of an SOM class, etc. troublesome to a beginner?

It leaps to INDEX.

### Creation of the application which displays the date and time

Since the head will become painful if only not much difficult one is done, it is a break. The hand was added to the sample currently introduced by guide to VisualAgefor Basic. The procedure of application development is reviewed by making easy application.

1. A start is from a setup of form first. The character which is made to display a property editor and is displayed on a title bar is inputted as a "clock" by the Caption item. Many of characters displayed on form or a component are set up by Caption.
2. Next, arrangement of a component. Two labels which display the date and time are arranged. When arranging more than one at this time, a label icon is clicked with a tool box, pushing the [Ctrl] key. Continuation arrangement mode After it is alike and carrying out, it clicks and arranges on form. It does not become large if the kind of font is not changed into enlarging the size of a font at this time.
3. A setup of the property of a label. The existence of the frame of a label is set up by the BorderStyle item. Here, FixedSingleBorder is chosen and a frame is attached.
4. Shortly, it is arrangement of a command button. Since a display button and two end buttons arrange, two are arranged using the command button of a tool box in continuation arrangement mode. For escaping from continuation arrangement mode, it is [Esc]. A key is pushed or it is a tool box. [Pointer] A button is clicked.
5. A setup of the property of a command button. The character displayed on a command button is inputted as "the display (&T) of date & time", and "an end (&X)" by the Caption item, respectively. Half-size alphabetic character inputted into Caption "&" Character Access key It is an important character for を設定(ing). & The half-size alphabetic character of one character specified to be the next can be set as an access key. Therefore, & character between the date and time is inputted [ full size ]. It seems that the character which sets up an access key is restricted to a half-size alphabetic character. It is [Alt] when an access key is set up. A command can be executed with the half-size alphabetic character specified while pushing the key. It seems that moreover, "X" is assigned as an access key for an end.
6. It is description of a code still more. The code of a "display of date & time" button is inputted using a code editor. A code is a Time function. A Date function is used and it is a label. It substitutes for Caption property.
   Label1.Caption=Date
   Label2.Caption=Time
7. Next, the code of an end button is described. Command2 is chosen in the place of "the object/class" of a code editor, and the following is inputted.
   Unload Me
   End
8. Now, syntax reference is performed. If errorless, application can be performed still more. Application can be performed if the "start" button of the tool bar of a code editor is pushed. The access key which shows the date and time is also working. The "end" button of the tool bar of a code editor is pushed, and it returns to design mode.
9. Work is kept. About the form contained in application, it is ".i" FAI. It is kept by the RU extension. In case a file or a project is kept for the first time, a name is named and kept to the file name and project name of each form of a project. "File" => "name and keep a name" of a project (Project) window is chosen. A file dialog box is displayed. Please input a new file name. The file name of form1.i is inputted. Next, it is storage of a project. The name of a project is inputted with ".prj" extension.

This is the execution screen of a program. Time Only the Date function was thought of. being such -- he studies little by little, making, although rubbed

It leaps to INDEX.

It leaps to < Vol 1. ■ Leap to a homepage.