MMCC MASTHEAD


INDEX

v1.10
Mid-Michigan Computer Consultants, Inc.
509 Center
Bay City, Michigan

Sales (989) 892-9242             Support (989) 686-8860


ANSI Standard PL/B Language
GENERAL TECHNIQUES
This page covers a number of notes and technques which don't necessarily need a full page treatment of their own.

Make your own SAMPLE CODE

Multi-line STATTEXTs

Nul Strings

LAYERED objects

ZORDER

Group box and Radio groups

Future tip


MAKE YOUR OWN SAMPLE CODE
Sunbelt has provided a lot of sample programs in the \SUNBELT\DEMO directory. But you don't always find what you're looking for.

You can use the Forms Designer to build your own samples. Just start a form, create the objects that you want, then "export" the code.

The "EXPORT" feature is found by placing the cursor over any unused portion of the form and right clicking. One of the options is EXPORT. Click that and you get a dialog box asking for the file name.

WARNING The file name for the export will be the current {fornmame.PLS}. If you have a program under that name it will be overwritten. Don't hurt yourself ! ! !

It may be tempting to build a form then export the code and go forward by hand. That's fine in some cases but be warned that it's a one way road. You cannot bring the exported code BACK INTO the designer.



MULTI-LINE STATTEXTs
What we want to do is to put up a STATTEXT that's a box then display several lines of data in it. What we get is one long line that runs out of the right margin of the STATTEXT box.

Making the box larger does not help. The text is still one long line running left to right but it DOES center top to bottom in the box.

In an ALERT box you can do a line feed using a HEX 7F (HEX_7F INIT 0x7F) . This makes a nicely formatted ALERT with data on several lines:

The answer from Sunbelt is that you CANNOT DO IT in a STATTEXT.

There are two solutions:
1: Use several small STATTEXTs in close proximity to each other. This gives the feel of a multi-line display but is more code to contend with.

2: Use an EDITTEXT instead of a STATTEXT.
        THIS WORKS BEST

Using this method you can build paragraph style informational boxes. The user can scroll up and down through your information.

Sometimes you may NOT want the scroll bars. But you may have to live with them.

PROPERTIES you may need to set:
        Set READONLY to $ON to prevent input.
        Maybe set STATIC to $ON.
        Set WORDWRAP to $ON.

Set MAXLINES high enough for your needs.
        THIS IS IMPORTANT!
Even if you use WORDWRAP to fill the box, you only get the number of lines that MAXLINES allows. The HEX 7F goes to the NEXT LINE... if you only have ONE line then everything else is chopped!



NUL Strings
This section has been moved to STRINGS.

NUL strings are simply string items which have no contents. That is the LENGTH POINTER is zero. When a string is created with a DIM instruction it is NUL by definition:
       NUL DIM 1

You cannot MOVE a nul string to another string. Nothing will happen.
     MOVE NUL to NAME
That MOVE will simply do nothing.

You CAN MOVE a blank string to another:
     MOVE " " to NAME or
     MOVE SPACE to NAME      (provided SPACE is predefined)
But moving a space to the output string will not create a NUL string. Instead it will create a one byte string containing one space.

THE TRICK:
There are two ways to make a string NUL (at least that I know about).
  1. Set the length pointer to 0:
          SETLPTR    NAME,0
    That works but it does not remove the original contents of the string. Normally that doesn't matter, but there are other instructions which can work on that string and still see the original contents. Sometimes that's what you want to do.

  2. Unpack a NUL string into the target:
          UNPACK    NUL,NAME
    The benefit of this trick is that UNPACK will initially set the target string to spaces then it will set the form pointer and length pointers to zero. Only then will it try to unpack the sending string into the target. Since the sending string is, itself, nul the target string will be left in a nul state.

    This UNPACK method works on strings, numeric variables (which are set to zero), LISTS items and ARRAYS.

    You DO have to pre-define NUL before doing this. We have a NUL variable by that name in our common work area which is incluced in every program we write.

    Some examples:
    NUL       DIM      1
    
    ADDRESS_BLOCK  LIST
    ACCOUNT   FORM     6
    NAME      DIM     30
    ADDRESS   DIM     30
    CITY      DIM     30
                   LISTEND
    
    TOTALS    FORM   7.2(10)
    			   
              UNPACK  NUL,  NAME           ;single field
              UNPACK  NUL,  ACCOUNT        ;make a number ZERO
              UNPACK  NUL,  ADDRESS_BLOCK  ;list structure
              UNPACK  NUL,  TOTALS         ;ZERO out an array
    


LAYERING OBJECTS
We have a situation which calls for us to "layer" some objects. In particular we need to put up a SHAPE (a square in this case) then put some STATTEXTs on top of it. We then need to be able to click on the box and note the click.

When we first did this we just put up the boxes. That worked fine and we were able to click on the box and react as needed.

Next we put the STATTEXT lines on top of the boxes. The problem was that now we could NOT click on the box ! Instead, the STATTEXT took the click event.

We tried several things to clear this up. The first guess was to use ZORDER. That, however, had no effect. The STATTEXT still masked out the click on the underlying box.

The solution proved to be very simple. We just DISABLED the STATTEXT object right after creating and activating it. The DISABLE leaves the object visible on the screen but does not allow any events to be noted.
DEMO_CODE          XXX                      ;comment


ZORDER This is an interesting note from David Garbler that was on the Sunbelt WebBoard

Topic: ZORDER ORDER (1 of 1), Read 38 times
Conf: Tips & Techniques
From: David Gabler
Date: Friday, July 10, 1998 02:56 PM

Just found this in PLBEQU.INC, and felt it deserved special mention in light of a small difficulty I had yesterday. I found that, regardless of what ZORDER I specified, I could not force a STATTEXT object on top of a BUTTON. An EDITTEXT, however (set to STATIC to mimic a STATTEXT) worked just fine. The reason? This is mentioned in PLB.HLP, but it outlined in more detail in PLBEQU.INC.

"ZORDER Description:
This property specifies which object should be displayed on top when more than one object exists in the same space and in the same plane.

Note1: Any objects in 'Plane 1' will always be on top of any object in 'Plane 0' with the exception of the TABCONTROL object. Although, the TABCONTROL object exists in 'Plane 1', the 'Plane 0' objects can be placed on top of the TABCONTROL by having a higher ZORDER value than the TABCONTROL.

BUTTON ;Plane 1
CHECKBOX ;Plane 1
CHECKGRP ;Plane 1
COMBOBOX ;Plane 1
DATALIST ;Plane 1
EDITTEXT ;Plane 1
GROUPBOX ;Plane 0
HSCROLLBAR ;Plane 1
ICON ;Plane 0
LINE ;Plane 0
MREGION ;Plane 0
MOVIE ;Plane 1
PICT ;Plane 0
PROGRESS ;Plane 0
RADIOGRP ;Plane 1
RADIO ;Plane 1
SHAPE ;Plane 0
SLIDER ;Plane 1
STATTEXT ;Plane 0
TABCONTROL ;Plane 1
VSCROLLBAR ;Plane 1
WINDOW ;No Plane objects (edittext, datalist, combo boxes, In general, when two objects contain the same ZORDER value, drawn objects (lines, shapes, icons, group boxes, pictures and static text) are displayed first. Window objects (etc.) are then displayed. "


Group box and Radio Groups

TIP 160

CONTENTS

v1.10
Send e-mail to MMCC.

Write to MMCC Technical Support at:
MMCC, Inc.
600 W. Midland
Bay City, MI 48708
(989) 686-8860
| Home   |

© 1997 MMCC, Inc. All Rights Reserved.

Report problems or suggestions to support@mmcctech.com
Site hosted by Molarnet Technologies

Since 09/14/1998