Main BASIS Page
Main Advantage Page
This Issue's Table of Contents
Bringing Visual PRO/5 to TAOS: The Developer's Workbench Previous Article Table of Contents Next Article

By William Baker

Randolph took two-and-a-half weeks to attend BASIS' two-day conference this year, which didn't surprise me at all. But I must admit I was surprised by his excuse for being away so long.

"Welcome, stranger," I said heartily as he hopped in. "Did you have a nice vaca-er-conference these last three weeks or so?"

"Humph, would you call two weeks of foot pain a vacation?" Randolph asked.

Drawing of Randolph at TechCon97 "Did you get injured?"

"Not exactly, but close enough. I spent two weeks soaking my feet in warm carrot juice because they were so sore. The hotel was so big I got lost and it took me an hour to find my room. I vowed not to go through that again, so instead of getting lost inside the hotel, I decided to hop around the outside of the hotel and get to the general area I needed to be, then take the closest entrance. That saved me from getting lost, but it meant hopping a mile or more at a time across asphalt and concrete. I missed parts of the sessions because I underestimated how long it would take. By the time I got home I could hardly crawl, much less hop. And that wasn't even the worst part."

"Oh?"

"The worst part was they had to have breakfast before the sessions started, so I missed both breakfasts. And they were good breakfasts, too, or so I heard," he said sadly.

"I can't imagine much worse than missing breakfast, except maybe missing dinner. But did you get to any of the conference? What was it like?" I asked.

"Oh, GUI this and GUI that. GUI front ends being shown off. Pretty screens, but none of them seemed to be written in TAOS."

"Did that inspire you to start moving to GUI development?"

"Mostly it inspired me to take naps. Of course, all the hopping had a lot to do with that."

"Well, I found something on BASIS' FTP site that might interest you. This screen isn't particularly pretty but it's GUI." I brought up a screen with two buttons and an entry field on it. "Look, I can type into this entry field and click the OK button and the value in the field changes. And I can click on the Exit button and the window goes away. I can see you're not impressed by that, but would you believe it's written in TAOS?"

"Sure I would, it's full of Visual PRO/5™ code-you've shown me that trick of putting 3GL code in a TAOS procedure."

"You're right that there's Visual PRO/5 code, but BASIS wrote all that, which is in an include file. The part I wrote is all in TAOS, and it just does GOSUBs to the Visual PRO/5 routines."

Randolph was moderately interested by this, and after fiddling with the buttons and the entry field for fifteen or twenty minutes, he let me explain my procedure.

Sample TAOS Graphical Windows "You see there's an include file, which is a few subroutines that do the GUI magic. The first thing my code does is open the channel for GUI display and input by invoking the OPEN_SYSGUI subroutine. Then I set a window title and run the subroutine that creates the window. Next I tell it to create buttons, a label, and an edit field with GOSUBs to each of those routines. Notice that the OK button has an ID of 101 and the Exit button has an ID of 102-that's important later."

"The heart of the logic is the REPEAT loop that starts by getting GUI events. You check the variable RWI__EVENT.CODE$ to see what kind of event has just happened on the screen. My procedure is specifically checking for an event code of B, which indicates a button has been clicked. It also checks RWI__EVENT.ID, which is the ID number of the button clicked. So if the event code is B and the ID is 102, we know the Exit button has been pressed and we terminate the program. If the ID is 101, we know the OK button has been clicked and fiddle with the display, but we could do real work here, like look up a record and display another window."

"Well, I guess it has possibilities," Randolph said, "and I can tell by that gleam in your eye you can't wait to show me all the complicated stuff in that include file, but my ankle has started throbbing again, so I think this will have to wait. Looks like it'll be another night of soaking for me."

With a great show of sighing and limping, Randolph painfully dragged himself off for another period of recuperation.

// Sample TAOS procedure using GUI subroutines

#include taos_vp5.h

gosub open_sysgui;
if rwi__sysgui=0 then
    {
    pause/warn "Not in a graphical environment";
    exit;
    }

rwi__title$="Sample TAOS Graphical Window";

/*
    Set height and width of window, in pixels.
These values may need to be adjusted depending on
monitor resolution. All other dimensions and
placements relate to character screen of 80
columns and 24 rows.
*/

rwi__h=300;
rwi__w=500;

gosub create_window;
this_window=rwi__context;

rwi__convert_xy=1;

rwi__id=101;
rwi__x=10;
rwi__y=10;
rwi__w=5;
rwi__h=1;
rwi__title$="Ok";
gosub create_button;

rwi__id=102;
rwi__x=20;
rwi__y=10;
rwi__w=5;
rwi__h=1;
rwi__title$="Exit";
gosub create_button;

rwi__id=103;
rwi__x=2;
rwi__y=4;
rwi__w=10;
rwi__h=1;
rwi__title$="Edit field:";
gosub create_label;

rwi__id=104;
rwi__x=10;
rwi__y=4;
rwi__w=20;
rwi__h=1;
rwi__title$="";
gosub create_edit;

repeat
    {
    gosub get_event;
    if rwi__event.code$="B" and rwi__event.id=102
    and rwi__event.context=this_window then
        break;
    if rwi__event.code$="B" and rwi__event.id=101
    and rwi__event.context=this_window then
        {
        rwi__id=104;
        gosub get_string_data;
        rwi__string_data$="Text entered: "+rwi__string_data$;
        rwi__title$=rwi__string_data$;
        gosub load_control;
        }
    }

gosub close_sysgui;
exit;

Editor's note: The include file discussed in this article is available at http://www.basis.com/advantage/mag-v1n2/taos_vp5.h.
 

Previous Article Table of Contents Next Article

 
 
Copyright 1999, BASIS International Ltd. All rights reserved.
Terms of Use
.