VisPro/REXX Is Visual Programming with REXX

From EDM2
Jump to: navigation, search

by Dave Hock

HockWare Inc.'s VisPro/REXX lets seasoned and novice PM programmers quickly create powerful graphical applications using REXX. VisPro/REXX uses the features of OS/2 2.1 and the Workplace Shell, and demonstrates the power of the OS/2 2.1 environment.

Many OS/2 programmers are using it to quickly construct applications that are critical to their business. Others are taking advantage of the OS/2 REXX support for database manager, HLLAPI, and APPC in building their applications.

VisPro/REXX looks and feels just like the Workplace Shell, making it extremely easy to learn. It employs direct editing, pop-up menus, multiple views, and settings notebooks. In addition, VisPro/REXX supports the OS/2 font and color palettes, making it easy to change the font or color of the application you are creating.

The fact that VisPro/REXX conforms to CUA '91 standards has another benefit: because developers often design by example when creating an application, programmers use design aspects of their favorite applications. Therefore, VisPro/REXX helps programmers design proper CUA '91 applications by acting as an example.

VisPro/REXX provides drag and drop capabilities throughout the product. The most distinctive of these is drag and drop programming. Using drag and drop, VisPro/REXX users literally have the option of programming a window with very little use of the keyboard. This capability is made possible by automatically generating REXX code for all object interactions.

VisPro/REXX has defined a series of powerful REXX calls to interface with GUI objects. These calls free the programmer from having to deal with the multitude of ways of accessing information on controls by using the object oriented programming (OOP) concept, overloading.

For example, consider the chore of getting the value of an OS/2 control. A VisPro/REXX programmer can use the VpGetItemValue function. In contrast, an OS/2 programmer would have to deal with many different types of calls, which vary from control to control. The following shows the programming constructs that are replaced by a single call to the function, VpGetItemValue:

To get the text for a push button, radio button, entry field, or check box:

WinQueryWindowText(hwnd,sizeof(value),value)

To get the text for a menu item:

WinSendMsg(hwndMenu, MM_QUERYMENUTEXT,
          MPFROM2SHORT(item,sizeof(value), value)

To get the position of a slider arm:

value=WinSendMsg(hwnd, SLM_QUERYSLIDERINFO,
          MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_RANGEVALUE),0)

To get the text of the selected item in a list box or combo box:

sTemp=SHORT1FROMMR(WinSendMsg(hwnd,LM_QUERYSELECTION,
          MPFROMSHORT(LIT_FIRST), 0));
     if (sTemp!=LIT_NONE)
        WinSendMsg(hwnd,LM_QUERYITEMTEXT,
                MPFROM2SHORT(sTemp,value),
                MPFROMP(value));

To get the contents of a spin button:

WinSendMsg(hwnd,SPBM_QUERYVALUE,
           MPFROMP(value),
           MPFROM2SHORT(sizeof(value),SPBQ_UPDATEIFVALID))

To get the contents of a selected value set cell:

mr=WinSendMsg(hwnd,VM_QUERYSELECTEDITEM,0,0);
     usRow=SHORT1FROMMR(mr);
     usColumn=SHORT2FROMMR(mr);
     vsText.pszItemText=value;
     vsText.ulBufLen=sizeof(value);
     WinSendMsg(hwnd,VM_QUERYITEM,
               MPFROM2SHORT(usRow,usColumn),MPFROMP(&vsText))

To get the text for a selected container icon:

pRecord=(PMINIRECORDCORE)PVOIDFROMMR(WinSendMsg(hwnd,CM_QUERYRECO
 RDEMPHASIS, MPFROMP(CMA_FIRST), MPFROMSHORT(CRA_SELECTED)));
    if (pRecord)
     if(WinSendMsg(hwnd,CM_QUERYRECORDINFO,
           MPFROMP(&pRecord), MPFROMSHORT(1)))
           strcpy(value,pRecord->pszIcon);

Who wants to do all this just to get the value of the object? VisPro/REXX does the equivalent operations with the single function, VpGetItemValue, and because of the drag and drop programming interface, programmers don't even have to type any code to achieve this.

Creating a Program using VisPro/REXX

To start working on a program, the VisPro/REXX user drags a new project from the Project template icon. Once open, the project displays a Main icon that represents the main window for the application being created.

From a pop-up menu, the VisPro/REXX user can open a Layout view of the Main icon. The WYSIWYG Layout view lets the user lay out the user-interface objects for the window. To add an object, drag the corresponding icons from the Tool bar, and drop them at the desired location in the canvas within the Layout view.

VisProREXX-Fig1.png

Figure 1. Layout view of VisPro/REXX

The objects you add behave just like Workplace Shell objects, including pop-up menus, support direct editing, and have a Settings view to modify attributes of the object. All objects can be dragged to the Shredder or to a Workplace Shell folder where they can be made into file objects. Objects can also be copied by holding down the Control key while dragging.

Add menus to the application using the Menu page of the Settings notebook. To add a menu, simply select Add menu from the Menu page. An icon appears for the menu; use direct editing to provide a name for it. Menu items can be added under the menu by selecting Add item; again, use direct editing to provide a name.

To define what happens when an object is used (for example, a button is clicked), you can either remain in the Layout view, or switch to the Event tree view. This view provides a split window, showing the objects the user added as well as the events the user chose on the left. On the right, the REXX statements for the selected event appear. If, for example, you want to specify what happens when a push button is clicked, select the When Clicked/Selected item from the push button's pop-up menu. The code for the event appears on the right side of the Event tree view.

The Event tree view is also handy for drag and drop programming. For example, to set the value of an entry field when the previously-described push button is selected, use drag and drop programming to drag the entry field to the right side (containing the code). At this point, linking emphasis is shown by a rubber-band line from the source of the drag to the current position of the mouse pointer. When the drag operation is ended, a window appears containing a list, in plain English, of all the things that can be done to the entry field. After the user selects the appropriate choice, the REXX statements used to set the value of the entry field are generated. See figure 2.

VisProREXX-Fig2.png

Figure 2. Event tree view showing drag and drop capabilities

After programming an initial application, test it by selecting the Test function. This function immediately runs the application, and places the programmer into an interactive debugger. While this debugger runs, the programmer can modify the code on the fly to correct any problems encountered. After the application is complete, the programmer can select the Build function to generate a small, stand-alone executable (.EXE) file. This file can be distributed to anyone free of charge.

HockWare History

HockWare, Inc. was formerly UCANDU Software. HockWare, Inc. is a software company specializing in OS/2 products. Dave Hock is a former member of IBM's CUA '91 Architecture group. He was a member of the programming team that developed the OS/2 2.0 Workplace Shell.