Print File

 Send a file to printer

Once builded a file contains lines to print, seems it’s easy sending that file to printer :

COPY FILE command send entire file to another file or a device :

COPY FILE <xcSourceFile> TO <xcTargetFile>|<xcDevice>

Arguments:

<xcSourceFile> is the name of the source file to COPY including the extension.

<xcTargetFile> is the name of the target file including the extension.

<xcDevice> is the name of the device where all subsequent output will be sent. You can specify a device name as a literal character string or a character expression enclosed in parentheses. Additionally, a device can be either local or network. If you COPY TO a non-existing device you create a file with the name of the device. When specifying device names, do not use a trailing colon.

Example :

COPY FILE Prnfile.txt TO LPT1

Remember that above last command doesn’t work under Windows. Almost all Clipper commands and functions are usable in Harbour. You can apply above tests with Harbour too. And the result not changed again. Because problem isn’t compiler, but hardware and OS difference. Harbour offers additional (extended) easy ways to manage printer(s) :

 WIN_PRINTEREXISTS()     (old name: PRINTEREXISTS())
 WIN_PRINTERSTATUS()     (old name: XISPRINTER())
 WIN_PRINTERPORTTONAME() (old name: PRINTERPORTTONAME())
 WIN_PRINTERLIST()       (old name: GETPRINTERS())
 WIN_PRINTERGETDEFAULT() (old name: GETDEFAULTPRINTER())
 WIN_PRINTERSETDEFAULT() (old name: SETDEFAULTPRINTER())
 WIN_PRINTFILERAW()      (old name: PRINTFILERAW())
For sending a file to printer we need only two of above function :
 WIN_PRINTERGETDEFAULT() 
 WIN_PRINTFILERAW()

If we have alredy above Prnfile.txt, sending it to printer seems easy :

 cDefaultPrinter := WIN_PRINTERGETDEFAULT() 
 WIN_PRINTFILERAW( cDefaultPrinter, Prnfile.txt )

Is that all ?

WIN_PRINTFILERAW() returns 1 if sending to printer was successful. If you test this, probably you will get 1.

May be easy like this ?

Unfortunatelly answer is “sometime” …

Although WIN_PRINTFILERAW() said “sending is successful” you may get nothing from printer.

What is meaning of “sometime” ? May be “sometime” in physic ?

In physic no, but in Windows yes !

What ?

Because some printers or some versions of Windows due to something obscure …

… doesn’t support “raw” printing 😦

And a more interesting thing :

You may send your “raw” file to printer via NotePad program of Windows :

cOutFName := "Test_Raw.txt"
cCmd := "NOTEPAD /P " + cOutFName

RUN ( cCmd)

( The “/P” parameter / switch means direct printing;  without NotePad open)

When sent this file by WIN_PRINTFILERAW() to printer noting happen, but by above (notepad) way sending is successful 😦

It seems that NOTEPAD build a “printable” document from our “raw” file and send this document to printer instead of our file.

However, NOTEPAD always add print file name to top, and page number to bottom of document; and treats our “printer control codes” as data, so printers never use them in “right”  way.

Other ways :

EXECUTE FILE "NOTEPAD.EXE" PARAMETERS cFileName

(  EXECUTE FILE   is a HMG command.

SHELLEXECUTE( 0, "print", cFileName )

Links

General :

HMG :

HMG-Web

HMG Forum 

HMG-Extended

OOHG : Object Oriented Harbour GUI

Marinas-GUI

Harbour :

The Harbour Project Home

HB_IDE

Common :

Alexander Kresin

Clipper… Clipper… Clipper

Programación Harbour (by Miguel Angel Juárez Apaza)

The Oasis: the largest file archive for Clipper and x-Base on the web

HMG Page by Pepe Ruano (Spanish)

The Holmes’s Clipper Page : Useful infos on Clipper

Various sources for Harbour Minigui

From CA-Clipper to Windows in 5 Minutes

Clipper to Harbour – A Visual Tour by Pritpal Bedi

Clipper On Line (Portugues)

Harbour MiniGUI Lights (Portugues)

Windows

Windows Programming

Other :

MinGW : Minimalist GNU for Windows

Crimson Editor : A professional source code editor for Windows.

Notepad++ : a free source code editor

PSPad : a freeware programmer’s editor

UPX : The Ultimate Packer for eXecutables

Inno Setup : A free installer for Windows programs.

GTK : A multi-platform toolkit for building graphical user interfaces.

Groups and mailling lists :

Harbour Project users’ mailing list

Harbour Project developers’ mailing list

Harbour Community in Google Plus

Harbour MiniGUI Discussion

xMate : a freeware project manager and builder

Harbour MiniGUI (HMG) En Español

MiniGUI em Português

Grupo ooHG : Minigui compatible Graphic Library, class based and oop programming

MiniGui Rutinas : Grupo para compartir cualquier tipo de rutinas de Minigui extended, HMG, OOH

Oficial mailing list: Marinas-GUI

Documentations :

Clipper:

ITL Programming

OOHG

Norton Guides (OuSob)

Norton Guides (x-hacker)

Dave Pearson

Harbour: 

Download / Install          

 How to build harbour for windows

 Harbour download and compile

Language references

Great guides and Tutorials by  Giovanni Di Maria

Official

Harbour Online Help

Harbour Language programming

FiveWin 

Vouch

OOHG

Marinas-GUI

Harbour collection Bis

HMG 

Official

 MiniGui Extended For Dummies

There are multiple news, discussion and mail groups about Clipper, Harbour and HMG. Surely, if you search, you will find more convenient to your needs. There are also a lot of individual web sites where you can obtain useful information on the subject.