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!











Sunday, June 10, 2012

Why did Manny Pacquiao lose to Timothy Bradley, Jr?

Why did Manny Pacquiao lose to Timothy Bradley, Jr?  In order for Manny to understand the meaning of true biblical Christianity as he was telling the whole world few months before the fight that he was converted to the true Christian faith. What is it? Well, it was written in the cloak of Evander Holyfield (a world boxing champion whose ear was bitten by Mike Tyson): "I can do all things through Christ who strengthens me" (Philippians 4:13).


Where's Freddie Roach, Manny's coach, or where's Pacquiao's strength? Well, it was all true before Manny's conversion, if it is true that he became a born-again Christian already. For God said that "I will not give my glory to another." God doesn't want Manny to glorify himself. God gave Manny Christian Lesson 101: "You will win Manny according to My will, not yours or Roach's.


 For My own sake, for My own sake, I will act;
For how can My name be profaned?
And My glory I will not give to another. Isaiah 48:11

Saturday, June 9, 2012

MingW error: Undefined reference to HB_FUN

Have you noticed that hbmk2 will always report an "undefined reference to HB_FUN_..." error if it cannot find the function you referred to or cannot find the library where the same function stayed? Here's an example of this error, especially so if you are using MingW compiler:

filexxx.c:(data+0x58): undefined reference to 'HB_FUN_FUNCTIONNAME'

BCC is more tolerant than MingW. I tried to compile a libmyLib.a where my functions relied on the codes in hbwin, hbxpp, and hbct libraries of Harbour contrib. You may try this experiment:


////// file mylib.prg
function try1()
  ? win_printergetdefault() // requires hbwin library
return nil



function try2()
   sleep(50) // requires hbxpp library
return nil

function try3()
  ? volserial() // requires hbct library
return nil



Try to compile the above codes using hbmk2, compiler=mingw, if you want to see the above error: undefined reference to HB_FUN...


Not only that, should you succeed by using the

 -l switch or
{mingw}libs=${hb_dir}libs${hb_name}.a  // (this switch worked for me)

in compiling your myLib library. For your next problem will be in the actual "swordfight" of your myLib library, since MingW cannot find easily whatever function you wrote in your myLib library. All you need to do is to hire big "L" switch, then the small "l" switch. The so-called big "L" tells the path, whereas, the lower case "l" tells about the library. Here's how to do it in your .hbp file or at the command line:



-LD:\myDir\myWork
-lmyLib (don't include the prefix (lib) and the file extension name, ".a"


Still these hbmk2 options won't work if you have imported functions from other libraries, f.e., hbwin.


Why? Because you need also to mention in your exe hbp the names of the contril libs where you based your myLib libraries.

I have this experience since I have functions in my XBase++ days which used XBTools III like volserial() which is very important to me. I want to share the following .hbp files, one for the lib, and the other for the exe file.

################## .hbp for the library file, example: myLib Library
## myLib.hbp


-inc
-w3 -es2
-workdir=HB/${hb_comp}
-hbx=blah.hbx        < try it, it's okey
{mingw}libs=${hb_dir}libs${hb_name}.a
-hblib
-info
-omyLib

 ################## .hbp for the exe file, example: try.exe
 ## try.hbp


-w3 -es2
-mt
-trace
-inc
-lhbxpp
-lhbct
-lhbwin
-LD:\dev\2012\myprog
-lmyLib
-info
-otry

Note that I am careful about the listing order of my libraries. From the forum, I learned Victor saying that ordering of libraries is a factor for the compiler.

My other blog on this topic may be of interest to you at My Harbour Notes: MingW cannot find my libraries.



Tuesday, June 5, 2012

MinGW can't find my libraries

 How to command MinGW using hbmk2 to read my own libraries during compilation of a Harbour source code? Unlike BCC, MinGW is always playing "hard-to-get" to newbies like me. So I made an experiment I would like to share with you. I created a library known as "myLib". With BCC the compiled file name will always be: myLib.LIB; whereas, with MinGW, a prefix "lib" is added to the file name, hence the resulting lib file would look like this:
"libmyLib.a". Note that the suffix is ".a", not ".lib".

1) First Step: Let's create a library.

////////////////////////////////// A program that returns the current path.
/////////////////////////////////// Usage: ? GetPath() --> D:\dev\lib
/////////////////////////////////// File name: trylib.prg
 FUNCTION GetPath()
  RETURN (DiskName()+":\"+CurDir())


2) Second Step: Let's compile our .prg named trylib.prg for us to produce libmyLib.a. In order to prepare our myLib library to contain more functions in the future we need to create an .hbp (Harbour project file. In XBase++, it is termed as .xpj file).

##  myLib.hbp - hbp filename.

# this .hbp file contains only one .prg named trylib.prg which contains a GetPath() function.  

# hblib is the hbmk2 option we need to use in creating a library

 -hblib

# for our compiler, let's use the -compiler switch. If you use a batch file, use
#    set HB_COMPILER=mingw

 -compiler=mingw

# switch -o is needed in order to control the name of the resulting output file.
# We want the name: myLib
-omyLib

# let's now include our .prg/s
trylib.prg

# done

3) Third Step: Let's write our main.prg, which will call our myLib library

/////////////////////////////////// A program that calls getpath() from myLib library
///////////////////////////////////              also known as libmyLib.a
/////////////////////////////////// Usage: just type try.exe at the dot prompt
/////////////////////////////////// File name: try.prg
FUNCTION Main()

cls

? getpath() // returns your current path

inkey(0)

RETURN NIL

4) Fourth Step: Let's write now our .hbp file for our project known as try.exe program. Use number sign "#" to make comments.

## try.hbp, the name of our .hbp file.

# for our compiler
-compiler=mingw

# if we want to control which directory hbmk2 has to do its compiling routines
# after your current path, you will find a new path HB\win\mingw
# hb_plat for platform; hb_comp for compiler

-workdir=HB/${hb_plat}/${hb_comp}

# this is key to command mingw to find your own library.
#     In my experience, mingw can't see your lib file even
#    if it is located in the directory where you compiled your source codes.
# use the following hbmk2 switch: an upper case "L" or -L then your path/current directory

-LD:\dev\lib


# note that in my experiment I didn't add the name of my library, just the path where my library stays.
# then I added another hbmk2 switch, -l, where I need to mention already the name of my library
# take note that this time it is small letter "l" or -l.

-lmyLib


# minGW created libmyLib.a, but I need to write only: -lmyLib


# the name of my output: try.exe, I need the switch -o
-otry


5) Fifth Step: We're almost done, but to make things easier and fast, let's create a batch file we call s.bat (s because I'm left-handed and I want to just easily press s on my keyboard for a trial-and-error compilation I am doing many times in the course of creating a software).

rem batch file name: s.bat
rem I want to set again my compiler, because I want to make sure. To avoid redundancy,
rem you may delete the one written in our .hbp, namely: -compiler=mingw

cls

set HB_COMPILER=mingw

hbmk2 myLib.hbp

rem after compiling our myLib library, we may delete already the above command

rem the added command "1>log.txt 2>&1 is for our log file necessary in tracing errors.

hbmk2 try.hbp 1>log.txt 2>&1

6. Sixth Step. At the command prompt type "dir" to see: try.exe and libmyLib.a. If you'll find them, it means you succeeded. Now is the time to type "try" to see it minGW finds your library. If you are successful you'll find something like this on your screen depending of course on the name of your path:

D> D>dev\myLib

Having the above on your screen, it means the function getpath() in our myLib library was successfully called by try.exe.

Thanks for the patience. Happy Harbour-ing!

Monday, June 4, 2012

How to save hbmk2's error messages?

If you are familiar with XBase++'s PBuild, you will notice that error messages during compilation are written into an "error.log." Do we have the same feature with our hbmk2? Of course the ">" (greater than) sign will normally save messages to a text file if you will place them in a batch file. For example:

                            try1.bat

                            c:> dir *.prg /b > log.txt

                            The result of the above command will look like this:

                                     try1.prg
                                     try2.prg, etc


In hbmk2, all you have to do in order to save error messages during compilation into a log file is this one (put together into a batch file):


                               try2.bat
              
                               set HB_COMPILER=mingw
                               hbmk2 try.hbp -rebuild 1> log.txt 2>&1

This above saves anything displayed on screen during complilation into a text file, in this example, log.txt.

Remove This copy of Windows 7 is not genuine Build 7600

How to remove this annoying message: "This copy of Windows 7 is not genuine Build 7600"? It was just a wink of an eye: your screen turned black then the above message. I surfed the Web and found RemoveWat.Exe for the solution of it.


After downloading it, I noticed a folder which has this name: RemoveWat 2.2.6 Hazar SCTV83.blogspot. I checked the properties of this free "Exe" and the following info came out:



Details

File Description           RemoveWat
Type Application File   Version 2.2.6.0
Copyright                    Copyright Hazar & Co. (c) 2010
Size                             6.35 MB
Date Modified             9/19/2010 9:05 PM
Language                    Language Neutral
Original Filename        RemoveWat

Judge for yourself if RemoveWat is not worthy of one's trust. I am so happy finding it, for it finally solved the "not genuine" mark in my desktop. Although RemoveWat didn't help my friend's computer, it perfectly helped mine and for it I wanted to suggest to one having the same problem to try RemoveWat (it removes "other things" also!).

Friday, May 18, 2012

Computer Suddenly Turning Off

My laptop suddenly turned off, losing all of my unsaved data as a result. I googled the problem immediately, but I found the same problem instead of a concrete solution of this computer-turns-off issue. Here's an example of what I gathered:


"Some would say it's overheating, but I don't think so, since it has a nice cooling and it didn't change from some time to now. I (just wonder, no clue) think it could be some voltage issue, some hard disk problem, power cable issue, possibly some wire overheating (!?!), maybe too many devices connected to the power socket. Could his be caused by any BIOS configuration? By the way, it's running with no memory or processor overclock."


A friend of mine told me that laptop's battery is sometimes problematic. In fact, the power icon of my laptop has a red "x" mark indicating that it is not charging. The reality however, is that it is functioning normally and useful within 20 minutes.
Annoyed, I made an experiment: I removed my laptop's battery and my laptop-turns-off-suddenly problem found a solution. It never went back.

Sunday, May 13, 2012

How to remove Chrome's insecure content alert

I am developing few sites using https://sites.google.com, but was so annoyed just recently of Chrome's "This Site has insecure content (Don't load, Load anyway)" alert in the pages of all my websites. One blogger wrote that I need to press CTRL+SHIFT+j to see what was causing it. Surprised, it was caused by google sites themselves.


Can you imagine the following causes--it's almost all google's or at least the word "google" such as "http://pagead2.googlesyndication.com/pagead/js...show_ads_impl.js".


The page at about:blank displayed insecure content from http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-5117933205504599&format=728x90_as&output=html&h=90&w=728&lmt=1336946874&host=pub-6693688277674466&ad_type=text_image&color_bg=FFFFFF&color_border=FFFFFF&color_link=000000&color_text=444444&color_url=0033CC&flash=11.2.202&url=https%3A%2F%2Fsites.google.com%2Fsite%2Fstrengthenedbythisverse%2F&dt=1336975683109&bpp=4&shv=r20120502&jsv=r20110914&prev_fmts=120x600_as&correlator=1336975683106&frm=20&adk=1335628509&ga_vid=1546748914.1336975221&ga_sid=1336975369&ga_hid=1490068524&ga_fc=1&u_tz=-480&u_his=13&u_java=1&u_h=768&u_w=1024&u_ah=728&u_aw=1024&u_cd=32&u_nplug=7&u_nmime=13&dff=arial&dfs=12&adx=199&ady=358&biw=1008&bih=667&oid=3&ref=https%3A%2F%2Fsites.google.com%2Fsite%2Fstrengthenedbythisverse%2Fsystem%2Fapp%2Fpages%2Fadmin%2Fappearance%2FpageElements&fu=0&ifi=2&dtd=642&xpc=XvnqvfMIXT&p=https%3A//sites.google.com.
The page at https://sites.google.com/site/strengthenedbythisverse/ ran insecure content from http://pagead2.googlesyndication.com/pagead/js/r20120502/r20120410/show_ads_impl.js.
2The page at https://sites.google.com/site/strengthenedbythisverse/ ran insecure content from http://pagead2.googlesyndication.com/pagead/expansion_embed.js.
The page at https://sites.google.com/site/strengthenedbythisverse/ ran insecure content from http://pagead2.googlesyndication.com/pagead/js/r20120502/r20120410/show_ads_impl.js.
The page at about:blank displayed insecure content from http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-5117933205504599&format=300x250_as&output=html&h=250&w=300&lmt=1336946874&host=pub-6693688277674466&ad_type=text_image&color_bg=FFFFFF&color_border=FFFFFF&color_link=000000&color_text=444444&color_url=0033CC&flash=11.2.202&url=https%3A%2F%2Fsites.google.com%2Fsite%2Fstrengthenedbythisverse%2F&dt=1336975683114&bpp=4&shv=r20120502&jsv=r20110914&prev_fmts=120x600_as%2C728x90_as&correlator=1336975683106&frm=20&adk=30073298&ga_vid=1546748914.1336975221&ga_sid=1336975369&ga_hid=1490068524&ga_fc=1&u_tz=-480&u_his=13&u_java=1&u_h=768&u_w=1024&u_ah=728&u_aw=1024&u_cd=32&u_nplug=7&u_nmime=13&dff=arial&dfs=12&adx=431&ady=983&biw=1008&bih=667&oid=3&ref=https%3A%2F%2Fsites.google.com%2Fsite%2Fstrengthenedbythisverse%2Fsystem%2Fapp%2Fpages%2Fadmin%2Fappearance%2FpageElements&fu=0&ifi=3&dtd=1430&xpc=ZFB4wjTJQx&p=https%3A//sites.google.com.
The page at https://sites.google.com/site/strengthenedbythisverse/ displayed insecure content from http://pagead2.googlesyndication.com/pagead/abglogo/adc-en-100c-000000.png.
The page at about:blank displayed insecure content from http://googleads.g.doubleclick.net/pagead/drt/s?v=r20120211.
The page at https://sites.google.com/site/strengthenedbythisverse/ displayed insecure content from http://pagead2.googlesyndication.com/pagead/abglogo/adc-en-100c-000000.png.
The page at about:blank displayed insecure content from http://googleads.g.doubleclick.net/pagead/drt/s?v=r20120211.
3The page at http://googleads.g.doubleclick.net/pagead/drt/s?v=r20120211 displayed insecure content from http://google.com/pagead/drt/ui.

I also followed "googleads.g.doubleclick.net" where one author (see hubpages) wrote in his page a blog entitled "What is http://googleads.g.doubleclick.net/ pagead/test_domain.js ? (By ) that his Kaspersky alerted him that this site was blocked due to password and credit card issues; but that an email from Kaspersky confirmed that it was just a false alarm, since this site was already bought by Google.

In one forum I followed the instruction of inserting the command-line option "--allow-running-insecure-content" and the message alert "insecure content" went away. (The reverse command in case you'll be interested is "--no-displaying-insecure-content"--if you want Chrome to go with its insecure content routine).

To insert the --allow-running-insecure-content command, go to Chrome's icon on your desktop (or at the start menu), right click, then go to Properties -> Shortcut, then Start in, and you'll find something like this: C:\Users\yourcomputername\AppData\Local\Google\Chrome\Application...at the end allow one space then paste or type: --allow-running-insecure-content.

Not the end of the story yet: Chrome continued to place a red mark on my "https" indicating that it just allowed, but the problem known as insecure-content is still there.

Others testified of a fully normal webpage browsing and total gmail insecure-content solution. But I was not as lucky. Of course, I will continue digging for other concrete solutions yet to this very annoying Chrome's security feature.


Friday, May 4, 2012

Full screen mode in Windows 7

I am no expert, but I have an experience about forcing your Windows 7 to display a full screen mode particularly on DOS programs. Windows thrust of forcing the world to obey it is always unacceptable. Time will come when Windows will see that the computer world is now slowly going against its submit-to-Windows-whims philosophy.

I love writing programs through using a DOS editor for long years. I have no problem with Windows XP; but Windows 7 is getting more unfriendly. I went to the Web and someone said that I needed to change the DISPLAY ADAPTER PROPERTIES. In short, all this trouble is adapter-related. I followed the instructions. He wrote that I have to "right click" at desktop and to PERSONALIZE -> DISPLAY -> ADVANCED SETTINGS -> ADAPTER -> PROPERTIES -> DISPLAY ADAPTER PROPERTIES -> BROWSE MY COMPUTER FOR DRIVER SOFTWARE, then click on LET ME PICK FROM A LIST OF DEVICE DRIVERS ON MY COMPUTER and select: STANDARD VGA GRAPHICS ADAPTER. Bingo! It worked.

But big problem. When I reinstalled my Windows 7, and have all these so-called updates in place, I could no longer find the "LET ME PICK UP FROM A LIST..." and no more SELECT STANDARD VGA GRAPICHS ADAPTER. Perhaps, such an option was no longer allowed in the newest updates.

Since my theory of Windows 7 not allowing full screen mode is adapter-related, I went directly to DEVICE MANAGER,  and disabled that very-controlling adapter there to see what would then happen. It worked.

Having no expertise, I could only say that doing so crippled consequently the good purpose (if it is really invented for the good - better ask Bill Gates!) for which the modern adapter was developed. To me, I have freed myself from my utter dislike with Windows 7 and that is the intentional crippling of full screen mode.

Good news: to disable your Windows 7 modern adapter is as easy as to enable it should your games or other programs be affected in the process. To do it, just right click at the COMPUTER icon on your desktop, then click DEVICE MANAGER, then look for DISPLAY ADAPTER. Depending on the device installed in your system, but in mine, I found under DISPLAY ADAPTER, "ATI Mobility Radeon HD 5000 Series". Double clicking it will lead you to a window and a prompt (click it!): DISABLE DEVICE.

Thursday, April 26, 2012

Entry point libiconv_set_relocation_prefix libiconv-2.dll


I didn't know what to do with this error at first: Error...Entry point
libiconv_set_relocation_prefix libiconv-2.dll. In my readings, I found
Victor saying concerning this error: "you met .dll hell." Yes, I did.
I deleted all occurrences of libiconv-2.dll and left only the ones
embedded in the hb31 nightly package. But still the "hell' didn't
leave me when I already deleted the same .dll in c:\Windows\System32.

Confused, I visited c:Windows\System32 and found there (again):
libiconv-2.dll. Did it resurrect? Anyway, I deleted it the second time
and pasted into c:\Windows\System32 libiconv-2.dll from hb31 in order
to stop its reproduction, if my theory proves right amidst my
ignorance of how did this broken dll found a place again at System32.
Then I ran hbmk2 and the "hell" went away. The problem was solved
which was caused by the libiconv-2.dll found in my c:\Window\System32.

I shared this experience for the others who will be meeting the same
error in the course of Harbour programming. Thanks to the Gurus who
give Harbour to the world for free.

For more information about Harbour Programming Language, please visit the following links:

http://groups.google.com/group/harbour-users?pli=1

http://www.harbour-project.org/


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.