Showing posts with label xBase. Show all posts
Showing posts with label xBase. Show all posts

Saturday, November 3, 2012

Ordlist() Function for Harbour, an Xbase++ function


There are functions in other xBase languages that are important, but are not in Harbour. One is Xbase++'s OrdList(). What's the work of OrdList()? Well, it lists the tag names of an index file. For example:

USE MySales.DBF
INDEX ON NAME         TAG NAMEX  TO SALES.CDX
INDEX ON ACCOUNT TAG ACCTX   TO SALES.CDX
...code
Running OrdList() we will get an array of tag names, which using the above example, will result in { NAMEX, ACCTX }.

Here's Xbase++'s documentation/example regarding OrdList():

 // OrdList()
// In the example, two index files for a customer file are created
// and then closed. The effect of the function OrdList() is
// shown.

   PROCEDURE Main
       USE Customer NEW EXCLUSIVE
      INDEX ON CUSTNO ;
           TAG C_Number ;
            TO CustA
       INDEX ON Upper(LASTNAME+FIRSTNAME) ;
           TAG C_LastName ;
            TO CustB
       SET INDEX TO CustA, CustB
       ? OrdList()          // Result: {C_NUMBER, C_LASTNAME}
       CLOSE Customer
    RETURN

I want the missing OrdList() in Harbour to be simulated, and the following is the code. (I limited my OrdName() up to 6 only, as it is the maximum based on my experiment. Our mentors out there know better. We may ask them through the Harbour Users Forum


FUNCTION MY_ORDLIST()
   LOCAL b,a:={},i
   SELECT ( Alias() )
   b:={OrdName(1),OrdName(2),OrdName(3),OrdName(4),OrdName(5),OrdName(6)}
   FOR i:=1 TO LEN( b )
       IF b[i] <> NIL
          aAdd( a, b[ i ] )
       ENDIF
   NEXT
RETURN a

May God bless our Harbour Family!











Thursday, March 1, 2012

From Xbase++ to Harbour

I've been searching for a Clipper-compatible compiler until I found Xbase++ and purchased, for my 3rd party libraries, the "Donnay" software and the Top Down (TD) Library developed by Clayton Jones. TD is so good, but I don't like my compiled .exe file to be dependent on dozens of .dll files. An Xbase++-compiled .exe file is like a post with strings, known as "dlls", attached to it to make it stand. One missing dll is enough to cripple my Xbase++-made software. Hence, I shifted to Harbour to serve my interest of a non-dll enslaved .exe file. Then my little Xbase experience became like a threshold of so huge a possibility when tied to the Harbour architecture.

I'm learning this robust language so slowly as I am interested to converted my Xbase++ programs to Harbour in a way intelligent and full of heart.

Since I want also to share my poor Harbour explorations, I decided to put up this blog, for the newbies like me to benefit from.

For example, I was so confused why is my Harbour GET command jumps up to the top of the screen, disobeying my command to stay at ROW==3. I went to the Users' Forum and Klas, one of Harbour's very popular names, told me to use SETMODE(25,80) to solve such a weird behavior.

What a good feeling it was that Harbour, a free language, is so loved by hundreds of computer gurus, who are committed to make Harbour a robust free language among the xBase dialects that are upgrading with the latest software technologies!

Not only that. Dozens of libraries are now bridged to Harbour, making non-native Harbour commands and functions to work with the Harbour compiler. Just imagine the possibilities such as the fact that Harbour can now be used to program such huge projects as developing robots!

Just google "harbour project" and lots of related sites will pop up to help us master Harbour, which is now getting very popular and dominant in the world today. You may be interested with the following links: www.harbour.project.org; en.wikipedia-org/wiki/Harbour-(software); sourceforge.net/projects/harbourproject.