Home page Home page Home page Home page
Pixel
Pixel Header R1 C1 Pixel
Pixel Header R2 C1 Pixel
Pixel Header R3 C1 Pixel
Pixel
By Sprezz | Friday 25 June 2010 14:58 | 0 Comments
Here at Sprezz Towers we're big fans of trying to write clean, maintainable code that lends itself to easy modification. As part of this, we like to keep our resource strings in a separate configuration row and pull them in at runtime using a call to one of our function libraries.

Today this technique rose up and bit us on the proverbial... consider the following code :-


begin case
  case memberRelatedCall= ''
    //* CTC012: Member call question must be answered|
    errorText := zzx_Utility( "RESSTR", RESKEY2$, "CTC012", "", 1)

You'll see that as a friendly reminder to following programmers we include the text of the error message as a comment before the call to retrieve the error text.

We were unit testing a module and ensuring that the appropriate errors messages were displayed when error conditions were found. But try as we might we couldn't get the errors to display and clearly incorrect data was somehow escaping validation.

This frustrated us no end. We single stepped through code and whilst the error condition was clearly there we just couldn't get it to set the error text to flag the exception. Even more mysteriously in the debugger we couldn't get the cursor to stop on the assignment of the error text.

Finally light dawned. As we were building up a potentially long error message we were including pipes in the literal as above. And whilst a pipe in a message means new line a pipe on the end of a program statement means the opposite - continue line. So our error text assignment was being seen as a comment and was not acted upon.

Of course if we'd thought to use #PRAGMA OUTPUT Table Row our mistake would have become immediately apparent.... hindsight eh?

As Homer so accurately says... D'oh!
By Captain C | Friday 11 June 2010 13:30 | 4 Comments
The Windows API provides a rich set of features for your application to utilise, but it can be a daunting task unless you’ve spent many hours programming in C/C++. Although the Windows API is well-documented on-line these days it can be a arduous task trying to map OI to Windows data types when prototyping functions and defining structures, or even searching C/C++ header files for constant definitions.

Here at Sprezz Towers we've done a lot of Windows API programming over the years and we've managed to amass quite a collection of DLL function definitions, structures and constants, and you can find them all in an RDK at the link below.

We've used some naming conventions with these so hopefully they don't collide with your own definitions:

DLL prototype records are prefixed "DLL_WINAPI_"
DLL functions are prefixed "WINAPI_"
Structures are prefixed "WIN32_"
Inserts are prefixed "WINAPI_"

A list of all the library components can be found in the RDK README.TXT file.


Enjoy!


Disclaimer

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Labels: , , , ,

By Captain C | 11:48 | 1 Comments
One of the more annoying visual traits we find with the EditTable is with single row selection: There seems to be no way to unselect a row and remove the highlight once it's there, and this can lead to a confusing state when it appears that more than one control has the focus.

We've often been asked how to rectify this as simply setting the SELPOS property doesn't suffice, so here's the solution - we use the Windows API SendMessage function to clear the selection like so...

   $insert logical
   
   equ DTM_SELROW$    to 1083 ; * // ( WM_USER + 59 )
   equ DTPOS_INVALID$ to -3

   hwndEdt = get_Property( @window : ".TABLE_1", "HANDLE" )
   call sendMessage( hwndEdt, DTM_SELROW$, FALSE$, DTPOS_INVALID$ ) 

Labels: , ,

Pixel
Pixel Footer R1 C1 Pixel
Pixel
Pixel
Pixel